Hi,
I have a user trying to use postgresql on windows but is having trouble
getting the basic stuff to work in Java. He has a sample program from
the postgres documentation he is testing with to make sure things work
but it is failing. He and I've read through the documentation but
haven't found a solution. Doing a google search it appears others have
also had this problem. No clear answer in their quest for answers.
Perhaps the solution should be in the faq and a note in the
documentation for windows on how the driver is made to work in windows.
The solution is probably something simple but I don't know much about
Java and he is fairly new to it so we don't know what we aren't doing
correct. It appears to me to be a problem with org.postgresql.Driver.
Do we need to rename one of the files we downloaded or does it need to
be in a particular directory? The user is fresh out of a class on Java
so doesn't know all he needs to know about compiler/environmental issues
that might be causing him problems (little practical experience). Any
hints/clues on what the solution might be would be helpful.
Here is the note from the user on his problem:
------------------------------------------------------------------------
Hi Experts,
I need HELP bad!! Been attempting to connect to the PostgresSQL
database without any success. Ensured all .jar files are in the class
path, database is running as a service but continue to receive the
following: JBuilder API Decompiler STUB SOURCE generated from class
file implementation of methods is not available. Or I receive this
message: java.lang.ClassNotFoundException: org.postgresql.Driver
at java.net.URLClassLoader$1.run(URLClassLoader.java: 202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.j ava:191)
at java.lang.ClassLoader.loadClass(ClassLoader.java:2 80)
at sun.misc.Launcher$AppClassLoader.loadClass(Launche r.java:275
at java.lang.ClassLoader.loadClass(ClassLoader.java:2 37)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:124)
at Database1.main(Database1.java:31). Please HELP, testing
program I'm using is as follows:
import java.sql.*;
public class Database1 {
public static void main(String[] argv) {
System.out.println(System.getProperty("java.class. path"));
System.out.println("Checking if Driver is registered with
DriverManager.");
try {
Class.forName("org.postgresql.Driver");
} catch (ClassNotFoundException cnfe) {
System.out.println("Couldn't find the driver!");
System.out.println("Let's print a stack trace, and exit.");
cnfe.printStackTrace();
System.exit(1);
}
System.out.println("Registered the driver ok, so let's make a
connection.");
Connection c = null;
try {
// The second and third arguments are the username and password,
// respectively. They should be whatever is necessary to connect
// to the database.
c =
DriverManager.getConnection("jdbc

ostgresql:\\loc alhost\\postgres",
"username", "password");
} catch (SQLException se) {
System.out.println("Couldn't connect: print out a stack trace and
exit.");
se.printStackTrace();
System.exit(1);
}
if (c != null)
System.out.println("Hooray! We connected to the database!");
else
System.out.println("We should never get here.");
}
}
Thanks in advance,
Mac