Thread: Error: ClassNotFoundException
Hello All, I'm a fairly experienced developer, however, a complete newbie when it comes to using PostgreSQL and JDBC. I have successfully installed PostgreSQL on my Mac G4 running Mac OS X 10.1. I'm able to start the DB daemon (with -i extension), I've created and populated a database (can query the database, etc.). When I installed PostgreSQL, I created a user account named "postgres" on my computer, and start the DB daemon while logged onto that account (in a console window after logging into the postgres account using 'su - postgres'). I've downloaded the pre-compliled jdbc7.1-1.1.jar JDBC driver. I put the JDBC driver file in /usr/local/pgsql/share/java. I've been trying to use JDBC to connect to a database and started with Marc Liyanage's example source file. When I try and run the executable after compilation I get an error. Specifically, the line of code in "Class.forName("org.postgresql.Driver");" returns the error "java.lang.ClassNotFoundException: org.postgresql.Driver". I'm at a bit of a loss. Do I have to register the JDBC driver? If I do, how do I do that? Could this be because the PostgreSQL daemon is running from a different account than I am running the JDBC test application from? Did I put the JDBC driver in the wrong directory? Would really appreciate the help. Thanks, Craig Lawton
On Fri, 26 Oct 2001 21:34:37 -0600, you wrote: >I have successfully installed >PostgreSQL on my Mac G4 running Mac OS X 10.1. I have no experience with this platform, but... >"Class.forName("org.postgresql.Driver");" returns the error >"java.lang.ClassNotFoundException: org.postgresql.Driver". ... typically means that the driver's jar file is not found or cannot be read by the Java runtime. Regards, René Pijlman <rene@lab.applinet.nl>
export CLASSPATH=$CLASSPATH:/usr/local/pgsql/share/java/jdbc7.1-1.1.jar:. You can keep ur driver anywhere but should be included in your CLASSPATH environment variable. Then execute ur program Jayesh > -----Original Message----- > From: Craig Lawton [SMTP:craiglawton@qwest.net] > Sent: Friday, October 26, 2001 8:35 PM > To: pgsql-jdbc@postgresql.org > Subject: [JDBC] Error: ClassNotFoundException > > Hello All, > > I'm a fairly experienced developer, however, a complete newbie when it > > comes to using PostgreSQL and JDBC. I have successfully installed > PostgreSQL on my Mac G4 running Mac OS X 10.1. I'm able to start the > DB > daemon (with -i extension), I've created and populated a database (can > > query the database, etc.). When I installed PostgreSQL, I created a > user account named "postgres" on my computer, and start the DB daemon > while logged onto that account (in a console window after logging into > > the postgres account using 'su - postgres'). I've downloaded the > pre-compliled jdbc7.1-1.1.jar JDBC driver. I put the JDBC driver file > > in /usr/local/pgsql/share/java. I've been trying to use JDBC to > connect > to a database and started with Marc Liyanage's example source file. > When I try and run the executable after compilation I get an error. > Specifically, the line of code in > "Class.forName("org.postgresql.Driver");" returns the error > "java.lang.ClassNotFoundException: org.postgresql.Driver". I'm at a > bit > of a loss. Do I have to register the JDBC driver? If I do, how do I > do > that? Could this be because the PostgreSQL daemon is running from a > different account than I am running the JDBC test application from? > Did > I put the JDBC driver in the wrong directory? > > Would really appreciate the help. > > Thanks, > > Craig Lawton > > > ---------------------------(end of > broadcast)--------------------------- > TIP 6: Have you searched our list archives? > > http://archives.postgresql.org
On Saturday 27 October 2001 03:32 am, Rene Pijlman wrote: > On Fri, 26 Oct 2001 21:34:37 -0600, you wrote: > >I have successfully installed > >PostgreSQL on my Mac G4 running Mac OS X 10.1. > > I have no experience with this platform, but... > > >"Class.forName("org.postgresql.Driver");" returns the error > >"java.lang.ClassNotFoundException: org.postgresql.Driver". > > ... typically means that the driver's jar file is not found or > cannot be read by the Java runtime. Right. The JVM is telling you that the class "org.postgresql.Driver" is not on your classpath. You need to add the jar containing the driver to your classpath. > > Regards, > René Pijlman <rene@lab.applinet.nl> > > ---------------------------(end of broadcast)--------------------------- > TIP 4: Don't 'kill -9' the postmaster -- ------------------------------------------------------------------- Isaac Sparrow Staff Engineer VisiComp, Inc. http://www.visicomp.com GnuPG Key Fingerprint: 1060 5A07 F6EC B2B3 9AAA 3EA5 7B79 EFE1 6397 4F47 Get my public key at: http://www.concentric.net/~issparow Latin is a language, As dead as can be. First it killed the Romans, And now it's killing me.
> I put the JDBC driver file in /usr/local/pgsql/share/java. Craig, Put the driver in /Library/Java/Home/lib/ext/ and see what happens. That's what did the trick for me. I'm still using 10.0.4, but I assume they didn't change that directory in 10.1. Jeremy Buchmann Programmer / Systems Admin Wells Gaming Research