From: Dave Cramer <pg@fastcrypt.com>
To: Mads N. Vestergaard <mnv@timmy.dk>
Cc: pgsql-jdbc@postgresql.org
Subject: Re: java.sql.SQLException: No suitable driver
Date: Thu, 27 Apr 2006 09:43:04 -0400
Message-ID: <B82B73E6-A7EC-462B-AE49-F934661CE9DF@fastcrypt.com> (raw)
In-Reply-To: <4450C7C4.7000503@timmy.dk>
References: <4450B6E2.3020503@timmy.dk>
<AEE99EF3-AC28-488F-AAC7-DE9B87FE1A03@fastcrypt.com>
<4450C7C4.7000503@timmy.dk>
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.
>>
>
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-jdbc@postgresql.org
Cc: pg@fastcrypt.com, mnv@timmy.dk
Subject: Re: java.sql.SQLException: No suitable driver
In-Reply-To: <B82B73E6-A7EC-462B-AE49-F934661CE9DF@fastcrypt.com>
References: <4450B6E2.3020503@timmy.dk> <AEE99EF3-AC28-488F-AAC7-DE9B87FE1A03@fastcrypt.com> <4450C7C4.7000503@timmy.dk> <B82B73E6-A7EC-462B-AE49-F934661CE9DF@fastcrypt.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox