Accessing InterClient Extensions to the JDBC

From InterBase

Go Up to Developing InterClient Programs


To access InterClient-specific classes and methods such as Driver, Connection, and Statement, you must cast your JDBC objects before applying the interbase.interclient method. However, you do not need to declare the original objects this way. Always create the object with a generic JDBC class, and then cast the object to the extended class; for example:

interbase.interclient.Driver
interbase.interclient.Connection
interbase.interclient.Statement

java.sql.ResultSet() interface does not have a function to check if a particular column has a value NULL. The InterBase JDBC driver provides an extension ResultSet.isNull(int) to check if a particular column in the returned record has the value NULL. You will need to explicitly qualify the call to the extended API with interbase.interclient.ResultSet as follows.

For example: The following example prints out a message when the column "phone_ext" is NULL for certain employees.

 
java.sql.ResultSet rs = s.executeQuery ("select full_name, phone_ext from employee where salary > 300000"); 
while (rs.next ()) { 
  System.out.println (rs.getString ("full_name"));

  // Use InterClient extension API to check for NULL 
  // Demonstrate use of InterClient extension to JDBC... 
  // ResultSet.isNull() is an extension. 
  // Since "rs" is defined to be of type java.sql.ResultSet 
  // this will not work ---> if (true == rs.isNull(2))
  // So, qualify the call to the extended API with interbase.interclient.ResultSet 
  
  if (true == ((interbase.interclient.ResultSet)rs).isNull(2))
  System.out.println ("Employee phone extension is NULL");}
Tip:
By using explicit casts whenever you need to access InterClient-specific extensions, you can find these InterClient-specific operations easily if you ever need to port your program to another driver.


Advance To: