Postgres Plus Forums: The PostgreSQL Open Source Database from EnterpriseDB
Search
Recent Topics
Hottest Topics
Member Listing
Back to home page
Can't get JDBC to compile. Please help.
Forum Index
»
ApachePHP and application Installers
Author
Message
12 Apr 2009 15:40:40
Subject:
Can't get JDBC to compile. Please help.
Kazi_S
New member
Joined: 12 Apr 2009 15:17:07
Messages: 1
Offline
I'm a beginner. I installed PostGRESQL 8.3 with edb_pgjdbc.exe (604) on Windows XP SP2.
The following test code won't compile:
package javaapplication1; import java.sql.*; public class Main { public static void main(String[] args) { try { helloPostgresql(); } catch (Exception ex) { System.out.println("***Exception:\n"+ex); ex.printStackTrace(); } } public static void helloPostgresql() throws ClassNotFoundException, SQLException { Class.forName("org.postgresql.Driver"); Connection db = DriverManager.getConnection("jdbc:postgresql:pathos", "postgres", "cuy4867z"); PreparedStatement st = db.prepareStatement("INSERT INTO test VALUES (?,?,?)"); st.setInt(1, 5); st.setString(2, "'$10.00'"); st.setString(3, "'full checkup'"); st.executeUpdate(); st.close(); db.close(); } }
NetBeans says:
***Exception: java.lang.ClassNotFoundException: org.postgresql.Driver java.lang.ClassNotFoundException: org.postgresql.Driver at java.net.URLClassLoader$1.run(URLClassLoader.java:200) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:188) at java.lang.ClassLoader.loadClass(ClassLoader.java:307) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301) at java.lang.ClassLoader.loadClass(ClassLoader.java:252) at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:169) at javaapplication1.Main.helloPostgresql(Main.java:36) at javaapplication1.Main.main(Main.java:24) BUILD SUCCESSFUL (total time: 0 seconds)
I've tried adding "E:\Program Files\PostgreSQL\pgJDBC" to the CLASSPATH. Any suggestions?
14 Apr 2009 10:08:07
Subject:
Re:Can't get JDBC to compile. Please help.
ashaar
Member
Joined: 28 Mar 2008 08:00:06
Messages: 88
Location: East Brunswick, NJ
Offline
Seems like a run time exception.
Please ensure that the class path is setup properly when the application is executed.
Thanks
15 Oct 2009 12:17:28
Subject:
Re:Can't get JDBC to compile. Please help.
scottiebo
Senior member
Joined: 23 Oct 2005 21:05:02
Messages: 197
Offline
Yeah, make sure that the jar file: (
http://jdbc.postgresql.org/download/postgresql-8.4-701.jdbc3.jar
) file is in your classpath.
--Scottie
Forum Index
»
ApachePHP and application Installers
Go to:
Select a forum
News & Announcements
Website Issues
Postgres Plus Cloud Database
Postgres Enterprise Manager
Advanced Server
Standard Server
Postgres Plus AMIs with Amazon EC2
GridSQL - General
GridSQL - Developers
PostgreSQL Installers for Windows, Linux and OS X
Tuning and Migration Wizard
ApachePHP and application Installers
Powered by
JForum 2.1.8
©
JForum Team