From: | Ernst Jan Plugge <rmc(at)dds(dot)nl> |
---|---|
To: | pgsql-jdbc(at)postgresql(dot)org |
Subject: | java.lang.ClassNotFoundException loading JDBC driver |
Date: | 2003-02-09 21:27:24 |
Message-ID: | Pine.LNX.4.44.0302092150370.3466-100000@hex.orbi |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-jdbc |
Hi,
Ik know this is a FAQ, but this looks different.
While loading the pgsql jdbc driver (using Class.forName() as the
documentation suggests) I get a ClassNotFoundException:
Exception in thread "main" java.lang.ClassNotFoundException:
org.postgresql.Driver
even though the JAR file _is_ on my classpath. I've tried both the
CLASSPATH environment variable, and the -cp command line argument. The
test app I use is extremely bare bones, uses nothing beyond JDBC, and only
tries to load the driver and establish a connection.
If I try to execute the class org.postgresql.Driver directly, with the
same classpath specification, the class is found, and I get (as expected)
an error message saying the class has no main method. This suggests that
my classpath is okay.
If I move the JAR file into the JVM's lib/ext directory, things work
perfectly. I need to be able to use the driver without doing that,
however. What am I doing wrong?
I'm using the pg73jdbc3.jar from jdbc.postgresql.org, downloaded today.
My JVM is j2sdk1.4.1_01 from Sun, on Red Hat Linux 8.0
I also tried the 7.2, 7.1 and 7.0 drivers, and JVM jdk1.3.1_06 from Sun.
(I used pg73jdbc2.jar instead of pg73jdbc3.jar there)
My test app is very simple:
import java.sql.*;
public class TestApp
{
public static void main( String argv[] ) throws
java.sql.SQLException, java.lang.ClassNotFoundException
{
Class.forName( "org.postgresql.Driver" );
String url = "jdbc:postgresql://dbhost:5432/test";
Connection conn = DriverManager.getConnection( url, "test", "xxxxxxxx" );
}
}
Ernst Jan
From | Date | Subject | |
---|---|---|---|
Next Message | John Cavacas | 2003-02-09 22:59:50 | JDBC Error codes |
Previous Message | David Wall | 2003-02-09 20:19:20 | Re: Is a right behaviour on inserting a duplicate key? |