Re: I can't connect to a database from application - Mailing list pgsql-jdbc

From Dave Cramer
Subject Re: I can't connect to a database from application
Date
Msg-id 1049223573.1108.116.camel@inspiron.cramers
Whole thread Raw
In response to I can't connect to a database from application  ("Miguel Angel Martin" <miguelangel.java@ozu.es>)
List pgsql-jdbc
Miguel,

This is the list for the postgres jdbc driver, the driver you are using
is the jdxbcon driver.

Dave
On Mon, 2003-03-31 at 17:21, Miguel Angel Martin wrote:
> I can't connect to a database from application but yes
> from IDE!.
>
> I use: Cygwin-postgresql 7.3.2   Win98  Netbeans 3.4  and
> JDK 1.4
>
> I Launch postgresql with the -i option to enable TCP/IP
> connections.
> No problem to connect to de database by the database
> option of the Runtime panel in Netbeans.  I can access all
> the tables, etc.  But, I can't  connect to the database
> from an application (inside Netbeans).   The source, to
> check the database access, is:
>
> import java.sql.*;
> public class postgres {
>      public static void main(String[] args) {
>          System.out.println("trying...");
>          try {
>              String url = new
>                  String("jdbc:postgresql:net//localhost:5432/basicportal");
>              String usr = new String("xxxx");
>              String pwd = new String(""); //postgres
> usr/password
>              System.out.println("finding driver...");
>              Class.forName("org.sourceforge.jxdbcon.JXDBConDriver");
>              System.out.println("creating
> driverManager...");
>              Connection db =
> DriverManager.getConnection(url,usr,pwd);
>              System.out.println("creating statement...");
>              Statement st = db.createStatement();
>              System.out.println("executing query...");
>              ResultSet rs = st.executeQuery("select * from
> base_content");
>              System.out.println("looping data...");
>              while(rs.next()) {
>                  System.out.print("Column 1 returned ");
>                  System.out.println(rs.getString(1));
>              }
>              System.out.println("loop finished, closing
> connection");
>              rs.close();
>              st.close();
>          }
>          catch( Exception e) {
>              System.out.println("Exception encountered: "
> + e);
>          }
>      }
> }
>
>
> And this is the output of the Output Window:
> trying...
> finding driver...
> creating driverManager...
> Exception encountered: java.lang.NullPointerException
>
> And the output of postgre in the Cygwin Window:
> "LOG:  pq_recvbuf: unexpected EOF on client connection"
>
>
> I'd put posgresql.jar  in
> netbeans\lib\ext
> myapplication\WEB-INF\lib
>
> and, later, in
> tomcat404\classes
> netbeans\tomcat404\lib
>
> Can anybody help me?
>
> Thanks !
>
>
> Miguel A. Martin
> Malaga - Spain
> --------------------------------------------------
> Nuevo Depósito a 1 mes 6% TAE, contrátalo:
> http://ingdirect.ozu.es
> --------------------------------------------------
> Correo enviado desde http://www.ozu.es
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org
--
Dave Cramer <Dave@micro-automation.net>


pgsql-jdbc by date:

Previous
From: "Henri Chen"
Date:
Subject: setObject() throw exception message: "The table for java.util.Date is not in the database. ..."
Next
From: Felipe Schnack
Date:
Subject: preparedstatment pooling