X-Original-To: pgsql-jdbc-postgresql.org@localhost.postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id 5C6F611F65A1 for ; Thu, 27 Apr 2006 10:43:23 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 26797-02-2 for ; Thu, 27 Apr 2006 10:43:07 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from net2.micro-automation.com (net2.micro-automation.com [64.7.141.29]) by postgresql.org (Postfix) with SMTP id 0A61C11F65C9 for ; Thu, 27 Apr 2006 10:43:04 -0300 (ADT) Received: (qmail 31173 invoked from network); 27 Apr 2006 13:43:05 -0000 Received: from dcdsl.ebox.com (HELO ?192.168.1.2?) (davec@64.7.143.116) by net2.micro-automation.com with SMTP; 27 Apr 2006 13:43:05 -0000 In-Reply-To: <4450C7C4.7000503@timmy.dk> References: <4450B6E2.3020503@timmy.dk> <4450C7C4.7000503@timmy.dk> Mime-Version: 1.0 (Apple Message framework v749.3) Content-Type: multipart/alternative; boundary=Apple-Mail-16-334459698 Message-Id: Cc: pgsql-jdbc@postgresql.org From: Dave Cramer Subject: Re: java.sql.SQLException: No suitable driver Date: Thu, 27 Apr 2006 09:43:04 -0400 To: Mads N. Vestergaard X-Mailer: Apple Mail (2.749.3) X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200604/172 X-Sequence-Number: 15106 --Apple-Mail-16-334459698 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed Mads, What is your classpath. inevitably this is the problem. Dave On 27-Apr-06, at 9:31 AM, Mads N. Vestergaard wrote: > Well, it gives me: > > java.lang.ClassNotFoundException: org.postgresql.Driver > at java.net.URLClassLoader$1.run(Unknown Source) > at java.security.AccessController.doPrivileged(Native Method) > at java.net.URLClassLoader.findClass(Unknown Source) > at java.lang.ClassLoader.loadClass(Unknown Source) > at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source) > at java.lang.ClassLoader.loadClass(Unknown Source) > at java.lang.ClassLoader.loadClassInternal(Unknown Source) > at java.lang.Class.forName0(Native Method) > at java.lang.Class.forName(Unknown Source) > at Database.(Database.java:16) > at Gateway.main(Gateway.java:19) > > But I think you're right... But my problem is, that if I try to run > it with the classpath flag, and also the classpath environment > vartiable, it fails. > The path is correct. > > I believe that I have overseen something, but I have looked over > the setup a dusin of times now, and I can't spot it. > > > Dave Cramer wrote: >> 5 will get you 10 that your class path isn't setup correctly. Try >> adding ex.printStackTrace() to the catch handler for Class.forName >> >> Dave >> On 27-Apr-06, at 8:19 AM, Mads N. Vestergaard wrote: >> >>> Hi Everybody, when I try to run my program, I get the following >>> error message: >>> java.sql.SQLException: No suitable driver >>> at java.sql.DriverManager.getConnection(Unknown Source) >>> at java.sql.DriverManager.getConnection(Unknown Source) >>> at Database.(Database.java:20) >>> at Gateway.main(Gateway.java:19) >>> Exception in thread "main" java.lang.NullPointerException >>> at Database.SQLget(Database.java:71) >>> at Gateway.main(Gateway.java:33) >>> My connect code is: >>> try { >>> Class.forName("org.postgresql.Driver"); >>> }catch (ClassNotFoundException e){ >>> } >>> try { >>> db = DriverManager.getConnection("jdbc:postgresql:// >>> hostname/" + dbName,"bruger","kode"); >>> } catch (SQLException e) { >>> e.printStackTrace(); >>> } >>> On my system I have putted the jdbc driver for postgres into the >>> classpath: >>> hostname:~$ echo $CLASSPATH >>> /usr/share/java/pg74.216.jdbc3.jar >>> Java version: >>> hostname:~$ java -version >>> java version "1.5.0_06" >>> Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_06- >>> b05) >>> Java HotSpot(TM) Client VM (build 1.5.0_06-b05, mixed mode, sharing) >>> As far as I know it should work since, it is correct in the >>> classpath. I have also tried with other postgres jdbc drivers. In >>> my IDE(Eclipse), it works fine, but on my production server it >>> gives the error. >>> I've also tried to run the program with the -classpath flag, with >>> the same result. >>> Have I simply forgotten something, or is there something >>> seriously wrong? >>> Thanks in advance. >> > --Apple-Mail-16-334459698 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=ISO-8859-1 Mads,

What is your = classpath.

inevitably this is the = problem.

Dave
On = 27-Apr-06, at 9:31 AM, Mads N. Vestergaard wrote:

Well, it = gives me:

java.lang.ClassNotFoundException: = org.postgresql.Driver
=A0=A0=A0=A0=A0=A0=A0 at = java.net.URLClassLoader$1.run(Unknown Source)
=A0=A0=A0=A0=A0=A0=A0 = at java.security.AccessController.doPrivileged(Native Method)
= =A0=A0=A0=A0=A0=A0=A0 at java.net.URLClassLoader.findClass(Unknown = Source)
=A0=A0=A0=A0=A0=A0=A0 at = java.lang.ClassLoader.loadClass(Unknown Source)
=A0=A0=A0=A0=A0=A0=A0 = at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
= =A0=A0=A0=A0=A0=A0=A0 at java.lang.ClassLoader.loadClass(Unknown = Source)
=A0=A0=A0=A0=A0=A0=A0 at = java.lang.ClassLoader.loadClassInternal(Unknown Source)
=A0=A0=A0=A0=A0= =A0=A0 at java.lang.Class.forName0(Native Method)
=A0=A0=A0=A0=A0=A0=A0= at java.lang.Class.forName(Unknown Source)
=A0=A0=A0=A0=A0=A0=A0 at = Database.<init>(Database.java:16)
=A0=A0=A0=A0=A0=A0=A0 at = Gateway.main(Gateway.java:19)

But I think you're right... But = my problem is, that if I try to run it with the classpath flag, and also = the classpath environment vartiable, it fails.
The path is = correct.

I believe that I have overseen something, but I have = looked over the setup a dusin of times now, and I can't spot it.
=

Dave Cramer wrote:
5 will get you 10 that your class path isn't setup = correctly. Try adding ex.printStackTrace() to the catch handler for = Class.forName

=
Dave
On 27-Apr-06, at 8:19 AM, Mads N. Vestergaard = wrote:

Hi =
Everybody, when I try to run my program, I get the following error =
message:
java.sql.SQLException: No suitable =
driver
=A0 =A0 =A0 =A0 at =
java.sql.DriverManager.getConnection(Unknown Source)
=A0 =A0=
 =A0 =A0 at java.sql.DriverManager.getConnection(Unknown Source)
=
=A0 =A0 =A0 =A0 at Database.(Database.java:20)
=
=A0 =A0 =A0 =A0 at Gateway.main(Gateway.java:19)
=
Exception in thread "main" java.lang.NullPointerException
=
=A0 =A0 =A0 =A0 at Database.SQLget(Database.java:71)
=
=A0 =A0 =A0 =A0 at Gateway.main(Gateway.java:33)
My =
connect code is:
try {
=A0 =A0 =
Class.forName("org.postgresql.Driver");
=A0 =A0 =A0 }catch =
(ClassNotFoundException e){
=A0 =A0 =A0 }
=A0 =
=A0 =A0 try {
=A0 =A0 =A0 =A0 db =3D =
DriverManager.getConnection("jdbc:postgresql://hostname/" + =
dbName,"bruger","kode");
=A0 =A0 =A0 } catch (SQLException =
e) {
=A0 =A0 =A0 =A0 e.printStackTrace();
=A0 =
=A0 =A0 }
On my system I have putted the jdbc driver for =
postgres into the classpath:
hostname:~$ echo =
$CLASSPATH
/usr/share/java/pg74.216.jdbc3.jar
=
Java version:
hostname:~$ java -version
=
java version "1.5.0_06"
Java(TM) 2 Runtime =
Environment, Standard Edition (build 1.5.0_06-b05)
Java =
HotSpot(TM) Client VM (build 1.5.0_06-b05, mixed mode, sharing)
=
As far as I know it should work since, it is correct in the =
classpath. I have also tried with other postgres jdbc drivers. In my =
IDE(Eclipse), it works fine, but on my production server it gives the =
error. 
I've also tried to run the program with the =
-classpath flag, with the same result.
Have I simply =
forgotten something, or is there something seriously wrong?
=
Thanks in advance.

=


= --Apple-Mail-16-334459698--