Esempio n. 1
0
 public QueryTableModel() {
   cache = new Vector();
   try {
     Class.forName("sun.jdbc.odbc.JdbcOdbcDriver").newInstance();
   } catch (java.lang.Exception e) {
     System.err.println("Class not found exception : ");
     System.err.println(e.getMessage());
   }
 } // konstr. sonu
Esempio n. 2
0
 public org.eclipse.swt.widgets.Shell open(org.eclipse.swt.widgets.Display display) {
   java.lang.Class clazz = org.eclipse.swt.examples.hoverhelp.HoverHelp.class;
   try {
     if (images == null) {
       images = new org.eclipse.swt.graphics.Image[imageLocations.length];
       for (int i = 0; i < imageLocations.length; ++i) {
         java.io.InputStream stream = clazz.getResourceAsStream(imageLocations[i]);
         org.eclipse.swt.graphics.ImageData source =
             new org.eclipse.swt.graphics.ImageData(stream);
         org.eclipse.swt.graphics.ImageData mask = source.getTransparencyMask();
         images[i] = new org.eclipse.swt.graphics.Image(display, source, mask);
         try {
           stream.close();
         } catch (java.io.IOException e) {
           e.printStackTrace();
         }
       }
     }
   } catch (java.lang.Exception ex) {
     System.err.println(
         getResourceString(
             "error.CouldNotLoadResources", new java.lang.Object[] {ex.getMessage()}));
     return null;
   }
   org.eclipse.swt.widgets.Shell shell = new org.eclipse.swt.widgets.Shell();
   createPartControl(shell);
   shell.addDisposeListener(
       new org.eclipse.swt.events.DisposeListener() {
         public void widgetDisposed(org.eclipse.swt.events.DisposeEvent e) {
           if (images != null) {
             for (int i = 0; i < images.length; i++) {
               final org.eclipse.swt.graphics.Image image = images[i];
               if (image != null) {
                 image.dispose();
               }
             }
             images = null;
           }
         }
       });
   shell.pack();
   shell.open();
   return shell;
 }
Esempio n. 3
0
  public void doGet(HttpServletRequest request, HttpServletResponse response)
      throws IOException, ServletException {
    response.setContentType("text/html");
    PrintWriter out = response.getWriter();
    ResultSet rs = null;
    try {
      // SET UP Context environment, to look for Data Pooling Resource
      Context initCtx = new InitialContext();
      Context envCtx = (Context) initCtx.lookup("java:comp/env");
      DataSource ds = (DataSource) envCtx.lookup("jdbc/TestDB");
      Connection dbcon = ds.getConnection();

      // ########### SEARCH INPUT PARAMETERS, EXECUTE search
      // #####################################################
      Vector<String> params = new Vector<String>();
      params.add(request.getParameter("fname"));
      params.add(request.getParameter("lname"));
      params.add(request.getParameter("title"));
      params.add(request.getParameter("year"));
      params.add(request.getParameter("director"));

      List<Movie> movies = new ArrayList<Movie>();
      movies = SQLServices.getMovies(params.toArray(new String[params.size()]), dbcon);

      // ########## SET DEFAULT SESSION() PARAMETERS ####################################
      request.getSession().removeAttribute("movies");
      request.getSession().removeAttribute("linkedListMovies");
      request.getSession().removeAttribute("hasPaged");
      request.getSession().setAttribute("hasPaged", "no");
      request.getSession().setAttribute("movies", movies);
      request.getSession().setAttribute("currentIndex", "0");
      request.getSession().setAttribute("defaultN", "5");

      // ########## IF MOVIES FROM SEARCH NON-EMPTY ###########################################
      List<String> fields = Movie.fieldNames();
      int count = 1;
      if (!movies.isEmpty()) {
        request.setAttribute("movies", movies);
        for (String field : fields) {
          request.setAttribute("f" + count++, field);
        }
        request.getRequestDispatcher("../movieList.jsp").forward(request, response);
      } else {
        out.println("<html><head><title>error</title></head>");
        out.println("<body><h1>could not find any movies, try your search again.</h1>");
        out.println("<p> we are terribly sorry, please go back. </p>");
        out.println("<table border>");
        out.println("</table>");
      }
      dbcon.close();

    } catch (SQLException ex) {
      while (ex != null) {
        System.out.println("SQL Exception:  " + ex.getMessage());
        ex = ex.getNextException();
      }
    } catch (java.lang.Exception ex) {
      out.println(
          "<html>"
              + "<head><title>"
              + "moviedb: error"
              + "</title></head>\n<body>"
              + "<p>SQL error in doGet: "
              + ex.getMessage()
              + "</p></body></html>");
      return;
    }
    out.close();
  }