Sample client code

COMPONENT JAVA
Extending the Power of JDBC Drivers
Nitin Nanda
Listing 5. Sample client code.


try
{
     Class.forName("com.jr.driver.JRDriver");

     Connection connection = DriverManager.
              getConnection("jdbc:jr:myDb","sa", "");

     Statement statement = connection.createStatement();

     //"testtable" is present in the DSN
     ResultSet resultSet = statement.
        executeQuery("select * from testtable");

     while(resultSet.next())
     {
	      /* do processing here */
     }
     
     resultSet.close();
     statement.close();
     connection.close();

}
catch(Exception exception)
{
     System.out.println(exception.getMessage());
     exception.printStackTrace();
}