// compile it by // javac *.java // // run it by // java -cp .:/usr/local/pgsql/java/devpgjdbc3.jar Hello import java.sql.*; class Hello { public static void main(String args[]) throws Exception { //register driver and connect to db for PostgreSQL Class.forName("org.postgresql.Driver"); Connection connection = DriverManager.getConnection( "jdbc:postgresql://sql.csic.umd.edu/YOUR_USERNAME", "YOUR_USERNAME", "YOUR_PASSWROD"); //As expected, the following codes are as same as the codes for Oracle Statement statement = connection.createStatement(); statement.executeUpdate("CREATE TABLE hello (value varchar(32))"); statement.executeUpdate("INSERT INTO hello VALUES('Hello world!')"); ResultSet res = statement.executeQuery("SELECT * FROM hello "); if (res != null) for(; res.next();) System.out.println(res.getString(1)); res.close(); statement.close(); connection.close(); } }