Need help setting up java and postgres -- updated
I've got Postgres installed and working. I've got Java installed and working. I got the postgres jdbc from the postgres site, put it where the docs said to, got the .jar files in the classpath and still no joy.
Details/versions:
psql 7.4.6
java version "1.5.0_01"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_01-b08)
grabbed pg74.215.jdbc3.jar and put it in /usr/share/java
symlinked /usr/share/java/postgresl.jar to pg74.215.jdbc3.jar
have tried $CLASSPATH=/usr/share/java/postgresql.jar:. and $CLASSPATH=/usr/share/java/:.
Used the test file at [link|http://www.telenovela-world.com/~spade/linux/howto/Enterprise-Java-for-Linux-HOWTO-6.html|http://www.telenovel...inux-HOWTO-6.html] under Confirming Your Installation. (Corrected the missing curly brace at the end.) Try to compile and get this:
drook@droogy:~/java/code$ javac PostgreSQLTest.java\nPostgreSQLTest.java:7: unreported exception java.lang.ClassNotFoundException; must be caught or declared to be thrown\nClass.forName("postgresql.Driver").newInstance();\n^\nPostgreSQLTest.java:7: unreported exception java.lang.InstantiationException; must be caught or declared to be thrown\nClass.forName("postgresql.Driver").newInstance();\n^\n2 errors
Googled for an hour to find that the code linked above doesn't catch all the exceptions. Added:
} catch (ClassNotFoundException cnfe) {\n System.out.println("ClassNotFoundException");\n System.out.println(cnfe.toString());\n
and a few other 'catch'es. Now get this:
drook@droogy:~/java/code$ java PostgreSQLTest\nClassNotFoundException\njava.lang.ClassNotFoundException: postgresql.Driver\n
Edited by
drewk
Jan. 14, 2005, 11:31:22 PM EST
Need help setting up java and postgres
I've got Postgres isntalled and working. I've got Java installed and working. I got the postgres jdbc from the postgres site, put it where the docs said to, and can't compile the test file.
Details/versions:
psql 7.4.6
java version "1.5.0_01"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_01-b08)
grabbed pg74.215.jdbc3.jar and put it in /usr/share/java
symlinked /usr/share/java/postgresl.jar to pg74.215.jdbc3.jar
have tried $CLASSPATH=/usr/share/java/postgresql.jar:. and $CLASSPATH=/usr/share/java/:.
Used the test file at [link|http://www.telenovela-world.com/~spade/linux/howto/Enterprise-Java-for-Linux-HOWTO-6.html|http://www.telenovel...inux-HOWTO-6.html] under Confirming Your Installation. (Corrected the missing curly brace at the end.) Try to compile and get this:
drook@droogy:~/java/code$ javac PostgreSQLTest.java
PostgreSQLTest.java:7: unreported exception java.lang.ClassNotFoundException; must be caught or declared to be thrown
Class.forName("postgresql.Driver").newInstance();
^
PostgreSQLTest.java:7: unreported exception java.lang.InstantiationException; must be caught or declared to be thrown
Class.forName("postgresql.Driver").newInstance();
^
2 errors
===
Purveyor of Doc Hope's [link|http://DocHope.com|fresh-baked dog biscuits and pet treats].
[link|http://DocHope.com|http://DocHope.com]