Lists: | pgsql-jdbc |
---|
From: | "Mads N(dot) Vestergaard" <mnv(at)timmy(dot)dk> |
---|---|
To: | pgsql-jdbc(at)postgresql(dot)org |
Subject: | java.sql.SQLException: No suitable driver |
Date: | 2006-04-27 12:19:46 |
Message-ID: | 4450B6E2.3020503@timmy.dk |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-jdbc |
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.<init>(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.
From: | Dave Cramer <pg(at)fastcrypt(dot)com> |
---|---|
To: | Mads N(dot) Vestergaard <mnv(at)timmy(dot)dk> |
Cc: | pgsql-jdbc(at)postgresql(dot)org |
Subject: | Re: java.sql.SQLException: No suitable driver |
Date: | 2006-04-27 13:25:41 |
Message-ID: | AEE99EF3-AC28-488F-AAC7-DE9B87FE1A03@fastcrypt.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-jdbc |
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.<init>(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.
From: | "Mads N(dot) Vestergaard" <mnv(at)timmy(dot)dk> |
---|---|
To: | pgsql-jdbc(at)postgresql(dot)org |
Subject: | Re: java.sql.SQLException: No suitable driver |
Date: | 2006-04-27 13:31:48 |
Message-ID: | 4450C7C4.7000503@timmy.dk |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-jdbc |
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.
>
From: | Dave Cramer <pg(at)fastcrypt(dot)com> |
---|---|
To: | Mads N(dot) Vestergaard <mnv(at)timmy(dot)dk> |
Cc: | pgsql-jdbc(at)postgresql(dot)org |
Subject: | Re: java.sql.SQLException: No suitable driver |
Date: | 2006-04-27 13:43:04 |
Message-ID: | B82B73E6-A7EC-462B-AE49-F934661CE9DF@fastcrypt.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-jdbc |
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.
>>
>
From: | "Mads N(dot) Vestergaard" <mnv(at)timmy(dot)dk> |
---|---|
To: | pgsql-jdbc(at)postgresql(dot)org |
Subject: | Re: java.sql.SQLException: No suitable driver |
Date: | 2006-04-27 13:46:33 |
Message-ID: | 4450CB39.1070205@timmy.dk |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-jdbc |
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.
>>>
>>
>
From: | Dave Cramer <pg(at)fastcrypt(dot)com> |
---|---|
To: | Mads N(dot) Vestergaard <mnv(at)timmy(dot)dk> |
Cc: | pgsql-jdbc(at)postgresql(dot)org |
Subject: | Re: java.sql.SQLException: No suitable driver |
Date: | 2006-04-27 13:56:50 |
Message-ID: | 37D75CA0-89B0-45F4-B183-88F06B3A3304@fastcrypt.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-jdbc |
Mads,
And how do you execute the program ? One thing that can help is to
run java -verbose to see what it is doing.
Dave
On 27-Apr-06, at 9:46 AM, Mads N. Vestergaard wrote:
> 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.
>>>>
>>>
>>
>
From: | "Mads N(dot) Vestergaard" <mnv(at)timmy(dot)dk> |
---|---|
To: | pgsql-jdbc(at)postgresql(dot)org |
Subject: | Re: java.sql.SQLException: No suitable driver |
Date: | 2006-04-28 09:11:49 |
Message-ID: | 4451DC55.70409@timmy.dk |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-jdbc |
Hi,
Well it gives me a lot of debug information. http://timmy.dk/debug.txt .
I ran:
hostname:~$ java -verbose -cp /usr/share/java/pg74.216.jdbc3.jar -jar
program.jar
Dave Cramer wrote:
> Mads,
>
> And how do you execute the program ? One thing that can help is to run
> java -verbose to see what it is doing.
>
> Dave
> On 27-Apr-06, at 9:46 AM, Mads N. Vestergaard wrote:
>
>> 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.
>>>>>
>>>>
>>>
>>
>
From: | Oliver Jowett <oliver(at)opencloud(dot)com> |
---|---|
To: | "Mads N(dot) Vestergaard" <mnv(at)timmy(dot)dk> |
Cc: | pgsql-jdbc(at)postgresql(dot)org |
Subject: | Re: java.sql.SQLException: No suitable driver |
Date: | 2006-04-28 10:03:53 |
Message-ID: | 4451E889.4070004@opencloud.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-jdbc |
Mads N. Vestergaard wrote:
> hostname:~$ java -verbose -cp /usr/share/java/pg74.216.jdbc3.jar -jar
> program.jar
>
-jar causes the JVM to completely ignore any additional classpath you
specify.
Instead, try:
java -cp /usr/share/java/pg74.216.jdbc3.jar:program.jar ProgramMainClass
-O
From: | "Mads N(dot) Vestergaard" <mnv(at)timmy(dot)dk> |
---|---|
To: | pgsql-jdbc(at)postgresql(dot)org |
Subject: | Re: java.sql.SQLException: No suitable driver |
Date: | 2006-04-28 10:06:09 |
Message-ID: | 4451E911.7010905@timmy.dk |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-jdbc |
Hi Aliver,
there isn't any conditional files in the environment variable CLASSPATH,
and the program runs fine, it just can't connect to the database.
Oliver Jowett wrote:
> Mads N. Vestergaard wrote:
>
>> hostname:~$ java -verbose -cp /usr/share/java/pg74.216.jdbc3.jar -jar
>> program.jar
>>
>
> -jar causes the JVM to completely ignore any additional classpath you
> specify.
>
> Instead, try:
>
> java -cp /usr/share/java/pg74.216.jdbc3.jar:program.jar ProgramMainClass
>
> -O
From: | Oliver Jowett <oliver(at)opencloud(dot)com> |
---|---|
To: | "Mads N(dot) Vestergaard" <mnv(at)timmy(dot)dk> |
Cc: | pgsql-jdbc(at)postgresql(dot)org |
Subject: | Re: java.sql.SQLException: No suitable driver |
Date: | 2006-04-28 10:24:57 |
Message-ID: | 4451ED79.6020000@opencloud.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-jdbc |
Mads N. Vestergaard wrote:
> Hi Aliver,
>
> there isn't any conditional files in the environment variable CLASSPATH,
> and the program runs fine, it just can't connect to the database.
I am talking about both the CLASSPATH environment variable and the -cp
command line argument. In my experience, if you specify -jar, both are
ignored and classes are only loaded from the standard locations, and the
single jarfile parameter given to -jar ("program.jar" in your case).
Have you tried the command line I suggested?
>> java -cp /usr/share/java/pg74.216.jdbc3.jar:program.jar ProgramMainClass
Please try this and let us know if it works.
I would also suggest that silently ignoring ClassNotFoundException, as
the code you originally posted does, is a Really Bad Idea. That code is
masking the real source of the error: namely, that the driver classes
are *not* in your classpath.
-O
From: | "Mads N(dot) Vestergaard" <mnv(at)timmy(dot)dk> |
---|---|
To: | Oliver Jowett <oliver(at)opencloud(dot)com> |
Subject: | Re: java.sql.SQLException: No suitable driver |
Date: | 2006-04-28 11:04:23 |
Message-ID: | 4451F6B7.6080009@timmy.dk |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-jdbc |
Hi Oliver...
That seems to work just perfectly....
Oliver Jowett wrote:
> Mads N. Vestergaard wrote:
>> Hi Aliver,
>>
>> there isn't any conditional files in the environment variable CLASSPATH,
>> and the program runs fine, it just can't connect to the database.
>
> I am talking about both the CLASSPATH environment variable and the -cp
> command line argument. In my experience, if you specify -jar, both are
> ignored and classes are only loaded from the standard locations, and
> the single jarfile parameter given to -jar ("program.jar" in your case).
>
> Have you tried the command line I suggested?
>
>>> java -cp /usr/share/java/pg74.216.jdbc3.jar:program.jar
>>> ProgramMainClass
>
> Please try this and let us know if it works.
>
> I would also suggest that silently ignoring ClassNotFoundException, as
> the code you originally posted does, is a Really Bad Idea. That code
> is masking the real source of the error: namely, that the driver
> classes are *not* in your classpath.
>
> -O
>
> ---------------------------(end of broadcast)---------------------------
> TIP 3: Have you checked our extensive FAQ?
>
> http://www.postgresql.org/docs/faq