Re: I can't connect to a database from application

From: Dave Cramer <Dave(at)micro-automation(dot)net>
To: Miguel Angel Martin <miguelangel(dot)java(at)ozu(dot)es>
Cc: pgsql-jdbc(at)postgresql(dot)org(dot)
Subject: Re: I can't connect to a database from application
Date: 2003-04-01 18:59:33
Message-ID: 1049223573.1108.116.camel@inspiron.cramers
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)postgresql(dot)org
--
Dave Cramer <Dave(at)micro-automation(dot)net>

In response to

Browse pgsql-jdbc by date

  From Date Subject
Next Message Felipe Schnack 2003-04-01 21:00:06 preparedstatment pooling
Previous Message Dave Cramer 2003-04-01 09:55:57 Re: setObject() throw exception message: "The table for