Re: Problem with connecting to postgres using jdbc7.0-1.2.jar

From: Rene Pijlman <rene(at)lab(dot)applinet(dot)nl>
To: Peter Adamek <peter(dot)adamek(at)utoronto(dot)ca>
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: Problem with connecting to postgres using jdbc7.0-1.2.jar
Date: 2001-12-24 08:06:33
Message-ID: bknd2u0r6k1rmc4872bnj5uotacetlqc4d@4ax.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

On Mon, 24 Dec 2001 00:33:41 -0500, you wrote:
>This may be a rookie mistake.
[...]
> try {Class.forName("org.postgresql.Driver");}
[...]
> try {db =
>DriverManager.getConnection("jdbc:postgresql:peter","padamek","");}
> catch (SQLException e) {}
> }

At first glance this looks OK (if you can logon using this
connect string and username, and without a password).

The most common rookie mistake is not to configure the
PostgreSQL server to accept incoming connections on a TCP/IP
socket.

Documentation is available on
http://jdbc.postgresql.org/doc.html,
http://www.postgresql.org/idocs/index.php?jdbc.html#JDBC-PREPARE,
http://www.fankhausers.com/postgresql/jdbc/ and
http://www.fankhausers.com/tomcat/jdbc/.

>When I compile it with the verbose javac option, here is what I get:

I don't see a problem in this log.

>When I try to run the servlet, I get the following error (it seems like
>the database connection is not being made - db is assigned a null
>value):

I don't see any mention of 'db' or PostgreSQL in this exception
stack trace.

>It seems strage to me that if I
>change the driver name that reads
>Class.forName("org.postgresql.Driver"), I get no errors when I compile.
>I could change it to Class.forName("heyYou") and it would still compile
>with no errors.

That's normal. Class.forName() is a runtime statement. You would
get another exception if this class can't be found at runtime.

>The other thing that seems strange is that if you look
>at the verbose output of my javac call, it seems like the sql
>DriverManagement and ResultSet classes are coming from the Java JDK
>1.3.1 install and not the postgres 7.0-1.2 JDBC java driver that was
>supplied from postgres.org.

The JDK provides the java.sql interfaces, the driver implements
them.

Have you tried to connect to the same PostgreSQL database from
the same client with a simple 'hello world' application that
does the same class.forName() and uses the same connect string?

Regards,
René Pijlman <rene(at)lab(dot)applinet(dot)nl>

In response to

Browse pgsql-jdbc by date

  From Date Subject
Next Message Rene Pijlman 2001-12-24 08:31:04 Re: date problem with postgres JDBC 7.1 driver
Previous Message Peter Adamek 2001-12-24 05:33:41 Problem with connecting to postgres using jdbc7.0-1.2.jar