A Sample Distributed Application

The JDBCExamples.java class contains three methods that illustrate distributed Java computing. These are all called from the main method.

Here is the getObjectColumn method from the JDBCExamples class.

private static void getObjectColumn() throws Exception {
// Return a result set from a column containing 
// Java objects 
    asademo.ContactInfo ci;
    String name;
    String sComment ;

    if ( conn != null ) {
      Statement stmt = conn.createStatement();
      ResultSet rs = stmt.executeQuery( 
           "SELECT JContactInfo FROM jdba.contact" 
    );
    while ( rs.next() ) {
    ci = ( asademo.ContactInfo )rs.getObject(1);
  System.out.println( "\n\tStreet: " + ci.street + 
      "City: " + ci.city + 
      "\n\tState: " + ci.state + 
      "Phone: " + ci.phone + 
      "\n" ); 
      }
    }
  }

The getObject method is used in the same way as in the internal Java case.

Related concepts
Connect From a JDBC Client Application Using jConnect