All Packages Class Hierarchy This Package Previous Next Index
The Adaptor interface is used to modify (adapt) the behavior of an InterClient JDBC object in order to improve performance for certain applications which do not require the full implementation of JDBC standard behavior for that object.
A JDBC class which implements this interface is said to be adaptable. The Adaptor interface can be implemented by any JDBC class which can be adapted for improved performance under certain assumptions. An adaptation modifies the default behavior for a JDBC object by compromising standard JDBC behavior in favor of performance.
Certain JDBC driver classes may choose to implement this interface for enhanced performance with the JBuilder dataset components. Currently, JBuilder only looks for ResultSet adaptations. Future versions of JBuilder may be able to use this for other InterClient package objects.
Here's an example adaptation of a result set object which instructs the driver to right trim CHAR string instances, and to avoid constructing multiple java.sql.Date instances by reusing the first Date fetched on each subsequent fetch.
import interbase.interclient.Adaptor; java.sql.Statement s = c.createStatement (); java.sql.ResultSet rs = s.executeQuery ("select NAME, BIRTHDAY from BIRTHDAYS"); Adaptor rsAdaptor = (Adaptor) rs; rsAdaptor.adapt (Adaptor.RIGHT_TRIM_STRINGS, null); rsAdaptor.adapt (Adaptor.SINGLE_INSTANCE_TIME, null); while (rs.next ()) { System.out.println (rs.getString ("NAME")); // no need to call trim() System.out.println (rs.getDate ("BIRTHDAY")); // The first Date object constructed is reused } // and modified throughout the iterations.
Additional modifiers may be added in future releases.
A third party tool built to run with any or multiple JDBC drivers could be compiled with this interface in its class path in order to leverage performance improvements when using the InterClient driver as follows:
java.sql.ResultSet resultSetToProcess = ... try { Class.forName ("interbase.interclient.Adaptor"); interbase.interclient.Adaptor adaptor = (interbase.interclient.Adaptor) resultSetToProcess; adaptor.adapt (SINGLE_INSTANCE_TIME, null); } catch (ClassNotFoundException e) { // no adaptor found, that's ok } process (resultSetToProcess);The performance of the 3rd party application will be greatly improved when InterClient is loaded as the JDBC driver backend, even if no other InterClient extensions are used, and the application makes only portable java.sql method calls.
Notice that a 3rd party tool provider needs to compile with the interbase.interclient.Adaptor interface in the class path, but does not need to compile with the complete interbase.interclient package unless it is using other InterClient extensions to the JDBC API.
Also notice that the Adaptor interface does NOT need to be shipped along with the 3rd party product. The Adaptor interface need not be present at run-time since the Adaptor declaration and call to adapt is only executed when the interbase.interclient.Adaptor class has been loaded.
InterClient VARs or those wishing to redistribute the Adaptor interface with a 3rd party app may prefer the following code:
import interbase.interclient.Adaptor; java.sql.ResultSet resultSetToProcess = ... if (resultSetToProcess instanceof Adaptor) { Adaptor adaptor = (Adaptor) resultSetToProcess; adaptor.adapt (SINGLE_INSTANCE_TIME, null); } process (resultSetToProcess);This Adaptor may be freely distributed along with 3rd party applications.
Other JDBC drivers may have their own peculiar adaptations and interfaces.
public final static int RIGHT_TRIM_STRINGS
public final static int SINGLE_INSTANCE_TIME
public abstract boolean adapt(int modifier, Object extraInfo) throws SQLException
public abstract void revert(int modifier) throws SQLException
All Packages Class Hierarchy This Package Previous Next Index