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 EAC0D11F60E5 for ; Thu, 27 Apr 2006 10:49:08 -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-04 for ; Thu, 27 Apr 2006 10:48:57 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from mail.jay.net (mail.jay.net [81.19.224.84]) by postgresql.org (Postfix) with ESMTP id EFE6411F65A1 for ; Thu, 27 Apr 2006 10:48:54 -0300 (ADT) Received: (qmail 18909 invoked by uid 509); 27 Apr 2006 13:48:55 -0000 Received: from 81.7.181.42 by mail.jay.net (envelope-from , uid 502) with qmail-scanner-1.24st (clamdscan: 0.87.1/635. spamassassin: 3.1.1 perlscan: 1.24st. Clear:RC:1(81.7.181.42):. Processed in 0.121039 secs); 27 Apr 2006 13:48:55 -0000 Received: from unknown (HELO server002.befree.dk) ([81.7.181.42]) (envelope-sender ) by mail.jay.net (qmail-ldap-1.03) with SMTP for ; 27 Apr 2006 13:48:55 -0000 Received: from [192.168.1.12] ([80.62.40.30]RDNS failed) by server002.befree.dk with InterScan Messaging Security Suite; Thu, 27 Apr 2006 15:48:23 +0200 Message-ID: <4450CB39.1070205@timmy.dk> Date: Thu, 27 Apr 2006 15:46:33 +0200 From: "Mads N. Vestergaard" User-Agent: Thunderbird 1.5 (X11/20060113) MIME-Version: 1.0 To: pgsql-jdbc@postgresql.org Subject: Re: java.sql.SQLException: No suitable driver References: <4450B6E2.3020503@timmy.dk> <4450C7C4.7000503@timmy.dk> In-Reply-To: Content-Type: multipart/alternative; boundary=------------070208050700080900030703 X-imss-version: 2.038 X-imss-result: Passed X-imss-approveListMatch: *@timmy.dk X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200604/173 X-Sequence-Number: 15107 This is a multi-part message in MIME format. --------------070208050700080900030703 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Hi Dave, My Classpath is: hostname:~$ echo $CLASSPATH /usr/share/java/pg74.216.jdbc3.jar And the file exists: hostname:~$ ls -la /usr/share/java/pg74.216.jdbc3.jar -rwxr-xr-x 1 root root 210371 2006-04-27 09:52 /usr/share/java/pg74.216.jdbc3.jar Dave Cramer wrote: > 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. >>> >> > --------------070208050700080900030703 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit
Hi Dave,
My Classpath is:

hostname:~$ echo $CLASSPATH
/usr/share/java/pg74.216.jdbc3.jar

And the file exists:
hostname:~$ ls -la /usr/share/java/pg74.216.jdbc3.jar 
-rwxr-xr-x  1 root root 210371 2006-04-27 09:52 /usr/share/java/pg74.216.jdbc3.jar

Dave Cramer wrote:
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.<init>(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.




--------------070208050700080900030703--