Re: forName finds Driver but getConnection doesn't (AGAIN)

From: Thomas Kellerer <spam_eater(at)gmx(dot)net>
To: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: forName finds Driver but getConnection doesn't (AGAIN)
Date: 2003-06-18 20:02:48
Message-ID: bcqgh2$jg1$1@main.gmane.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

Deepak Vasudevan K P schrieb:
> Hi all,
> I'm in the same situation where Dennis King was on 19 Nov 2002.
> I'm trying to connect to pgsql using JDBC (on a RHL 8.0) and for me,
> as it was with Dennis, forName registers the Driver, but getConnection
> throws the exception "Driver not found".
> I use JDK 1.3.1,
> tried postgresql JDBC driver: "pg72jdbc2.jar" from
> http://jdbc.postgresql.org/
> running java as : $>java -cp ./pg72jdbc2.jar <myClassFile>
> The source for myClassFile has the following specs
> Class.forName("org.postgresql.Driver");
> ...
> Driver.getConnection("jdbc:postgresql:postgres","postgres"); //
> throws the "Driver Not Found" exception.
> <Here '*postgres' *is the database name and '*postgres' *is a user>
>
> BTW I tried the same Driver in Windows (2000 prof, jdk1.4.1, forte for
> Java) and there getConnection worked, but the connection was refused by
> the RHL DB host (I've edited the pg_hba.conf file). That was just a try,
> I'd stick to RHL.
>
So far it looks fine to me. The only thing that strikes me, is the way you
define your classpath. Did you try:

java -cp .:pg72jdbc2.jar myClass

If the .jar file is in the current directory, I don't see a reason to
qualify it with a ./ at the beginning. Including the current directory
might help as well.

Thomas

In response to

Browse pgsql-jdbc by date

  From Date Subject
Next Message Paul Thomas 2003-06-18 20:05:34 Re: forName finds Driver but getConnection doesn't (AGAIN)
Previous Message Deepak Vasudevan K P 2003-06-18 18:49:34 forName finds Driver but getConnection doesn't (AGAIN)