Developer's Daily Java Education - Test Projects
  front page | java | perl | unix | DevDirectory
   
Front Page
Java
Education
   
 


import java.sql.*;

public class Main
{

  public Main()
  {
    try
    {
      System.err.println( "Starting ..." );
      Class.forName("org.postgresql.Driver");

      System.err.println( "conn..." );
      Connection conn = DriverManager.getConnection("jdbc:postgresql://myServer/myDatabase","myUsername", "myPassword");
      String tableName = "myTable";

      Statement st = conn.createStatement();
      ResultSet rs = st.executeQuery("select * from " + tableName);
      while ( rs.next() )
      {
        String s = rs.getString(1);
        System.out.println( "s = " + s );
      }
    }
    catch (Exception e)
    {
      System.err.println( "e: " + e.getMessage() );
    }
  }

  public static void main(String[] args)
  {
    Main main1 = new Main();
  }

}
Copyright 1998-2003 DevDaily Interactive, Inc.
All Rights Reserved.