Re: Problem connecting by JDBC with a SERVLET

Поиск
Список
Период
Сортировка
От Paulo Delgado
Тема Re: Problem connecting by JDBC with a SERVLET
Дата
Msg-id 20020228185912.24e1ef52.pdelgado@pasaportevip.com
обсуждение исходный текст
Ответ на Problem connecting by JDBC with a SERVLET  (Andres Davila <adavila0026@yahoo.com>)
Список pgsql-jdbc
Andres, which error message do you get? (it would help a lot)
Si quieres, puedes escribirme en español, directamente, no a la lista, no creo que les guste =)

On Thu, 28 Feb 2002 15:46:27 -0800 (PST)
Andres Davila <adavila0026@yahoo.com> wrote:

> I try to access a database on a Linux server, with
> Apache, Tomcat & Postgres.
>
> The servlet should connect to the database, make a
> select and display the results in a webpage
>
> My code is the following:
>
>  Connection con = null;
>          Statement stmt = null;
>          ResultSet rs = null;
>
> res.setContentType("text/html");
> PrintWriter out = res.getWriter();
>
> try {
> String database = "intvuelos";
>     String username = "nobody";
>     String password = "";
>     Class.forName("org.postgresql.Driver");
>
>  con =
> DriverManager.getConnection("jdbc:postgresql://10.65.28.12/invuelos",
> username, password);
> stmt = con.createStatement();
>  rs = stmt.executeQuery("SELECT numeroempleado,
> origen, destino FROM viajes");
>
>         out.println("<html><head><title>Consulta de
> Datos</title></head>");
>         out.println("<body>");
>
>         out.println("<ul>");
>
>             while(rs.next()){
>
>         out.println("<li>"+
> rs.getString("numeroempleado") + " " +
> rs.getString("nombre") + " " +
> rs.getString("apellidos"));
>
>            }
>         out.println("</ul>");
>         out.println("</body></html>");
>         }
>
>
>         catch(ClassNotFoundException e){
>  out.println("Couldn't load database driver: " +
> e.getMessage());
>                 }
>                 catch(SQLException e){
>  out.println("SQLException caught: " +
> e.getMessage());
>                       }
>     finally{
>                try{
>         if(con !=null) con.close();
>               }
>         catch (SQLException ignored){ }
>         }
>     }
>    }
>
> ****
>
>
> Please help me if you can
>
>
>
>
> __________________________________________________
> Do You Yahoo!?
> Yahoo! Greetings - Send FREE e-cards for every occasion!
> http://greetings.yahoo.com
>
> ---------------------------(end of broadcast)---------------------------
> TIP 5: Have you checked our extensive FAQ?
>
> http://www.postgresql.org/users-lounge/docs/faq.html

В списке pgsql-jdbc по дате отправления:

Предыдущее
От: "Dave Cramer"
Дата:
Сообщение: Re: Problem connecting by JDBC with a SERVLET
Следующее
От: "Eduardo José Hernández Cisneros"
Дата:
Сообщение: JDBC driver in Windows machines