Thread: Trying to get jdbc to work

Trying to get jdbc to work

From
"Mark Muffett"
Date:
Setup is postres on one machine, java client on another, very simple code:

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;


public class SimpleConnection {
    static public void main (String args[]) {
        Connection connection = null;

        if (args.length != 4) {
            System.out.println("Syntax: java SimpleConnection DRIVER URL UID
PASSWD");
            return;
        }
        try { // load the driver
            Class.forName(args[0]);
        }
        catch (Exception e) {
            e.printStackTrace();
            return;
        }
        try {
            connection = DriverManager.getConnection(args[1], args[2],
args[3]);

            System.out.println("Connection succesful!");
        }
        catch (SQLException e) {
            e.printStackTrace();
        }
        finally {
            try {
                connection.close();
            }
            catch (SQLException e) {
                e.printStackTrace();
            }
        }
    }
}

CLASSPATH=/usr/lib/java/lib/classes.zip:/usr/share/java/postgresql.jar:.

Error message:

/export/home/markm/Java/test > java SimpleConnection org.postgresql.Driver
jdbc:postgress://l2/template1 markm xxx
java.lang.NoClassDefFoundError: java/util/ArrayList
        at org.postgresql.core.ConnectionHook.<init>(ConnectionHook.java:53)
        at
        at
        at SimpleConnection.main(SimpleConnection.java:16)

I built Postgresql myself with the java option.  OS is Linux, JDK1.3

Any ideas???

Mark Muffett



Re: Trying to get jdbc to work

From
Holger Klawitter
Date:
> CLASSPATH=/usr/lib/java/lib/classes.zip:/usr/share/java/postgresql.jar:.


> /export/home/markm/Java/test > java SimpleConnection org.postgresql.Driver
> jdbc:postgress://l2/template1 markm xxx
> java.lang.NoClassDefFoundError: java/util/ArrayList

> I built Postgresql myself with the java option.  OS is Linux, JDK1.3

/usr/lib/java/lib/classes.zip is not 1.3 (probably a leftover from an
oder version). Remove it from your CLASSPATH (of your client) and you
should be fine.

With kind regards / Mit freundlichem Gruß
    Holger Klawitter
--
Holger Klawitter
holger@klawitter.de                             http://www.klawitter.de