[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[cobalt-developers] jdbc and postgres



I've looked through the archives and I can't find the
answer to my particular question.

I've put the postgres jdbc jar file "jdbc6.5-1.2.jar"
into /usr/java/jakarta-tomcat/lib directory and edited
the /etc/profile.d/java.sh such that the classpath
includes the jar. I've written a little java class to
connect but I get an error saying it can't find the
class. What do you think i've done wrong. Other posts
indicate putting the jdbc file into the lib
directory..done. Other posts indicated putting the
classpath line in..done. I'm stumped.

Thanks for your help
-
-
TestPG.java:
-------------
import java.sql.*;

class TestPG {
        public static void main (String[] args) {
        Connection conn = null;
        Class.forName("org.postgresql.Driver");
        conn =
DriverManager.getConnection("jdbc:postgresql:XXX","XXX","XXX");
        conn.close();
        }
}

Error Msg:
----------
TestPG.java:6: unreported exception
java.lang.ClassNotFoundException; must be caught or
declared to 
 be thrown
        Class.forName("org.postgresql.Driver");
             ^
TestPG.java:7: unreported exception
java.sql.SQLException; must be caught or declared to
be thrown
        conn =
DriverManager.getConnection("jdbc:postgresql:STAR","ghay","november");
                            ^
TestPG.java:8: unreported exception
java.sql.SQLException; must be caught or declared to
be thrown
        conn.close();
            ^
3 errors

_______________________________________________________
Build your own website in minutes and for free at http://ca.geocities.com