Connecting PostgreSQL with Java

  1. Logon to Cubist
  2. Add the following line in your .login file in your root directory, create one if it isn't in your root directory.

    setenv CLASSPATH /usr/local/pgsql/share/java/postgresql.jar:.

    Make sure your put the colon-dot ":." after postgresql.jar

  3. Exit and Re-logon to cubist
  4. Copy the Database.java file onto your cubist directory
  5. Compiler the file and exexcute it
  6. [xxx@cubist~]$ javac Database.java
    [xxx@cubist~]$ java Database

  7. Now you should see the output looks like:
  8. Successfully connected to PostgreSQL on cubist!
    Beer name is Bud
    Beer name is Heineken
    Beer name is Rainier
    Beer name is Becks
    Beer name is Samuel Adams
    Beer name is Corona
    Beer name is Tecate

  9. Email me if you run into any problems.