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 3E73D11F6B0F for ; Thu, 27 Apr 2006 10:35:49 -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 20800-10 for ; Thu, 27 Apr 2006 10:34:34 -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 1A5F011F6AD5 for ; Thu, 27 Apr 2006 10:34:09 -0300 (ADT) Received: (qmail 10179 invoked by uid 509); 27 Apr 2006 13:34:09 -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.065555 secs); 27 Apr 2006 13:34:09 -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:34:09 -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:33:40 +0200 Message-ID: <4450C7C4.7000503@timmy.dk> Date: Thu, 27 Apr 2006 15:31:48 +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> In-Reply-To: Content-Type: multipart/alternative; boundary=------------080208030408010108040905 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/171 X-Sequence-Number: 15105 This is a multi-part message in MIME format. --------------080208030408010108040905 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit 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. > --------------080208030408010108040905 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit 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.


--------------080208030408010108040905--