borland Packages  Class Hierarchy  sql Package 

SQLAdapter interface

com.borland.sql.SQLAdapter

About the SQLAdapter interface

Variables  Methods  

Implemented by RResult

Note: This is a feature of JBuilder Enterprise.

The SQLAdapter interface can be implemented by any JDBC class which can be adapted for improved performance. A JDBC class which implements this interface is said to be adaptable. 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 data set components. Currently, JBuilder only looks for ResultSet adaptations. Future versions of JBuilder may be able to use this for other java.sql 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 container fetched on each subsequent fetch.

Statement s = c.createStatement ();
ResultSet rs = s.executeQuery ("select NAME, BIRTHDAY from BIRTHDAYS");
SQLAdapter rsSQLAdapter = (SQLAdapter) rs;
rsSQLAdapter.adapt (SQLAdapter.RIGHT_TRIM_STRINGS, null);
rsSQLAdapter.adapt (SQLAdapter.SINGLE_INSTANCE_TIME, null);
while (rs.next ()) {
	rs.getString ("NAME");
	// no need to call trim()
	rs.getDate ("BIRTHDAY");
	// The first Date object constructed is reused
	// and modified throughout the iterations.
} 

Additional modifiers may be added in future releases.


SQLAdapter variables

Variables defined in this interface

SQLAdapter methods

Methods defined in this interface


SQLAdapter variables

RESETABLE_STREAM

  public final int RESETABLE_STREAM
Instructs driver to ensure streams returned will reposition to 0 position on a binary field value when the InputStream.reset() method is called. Also expects that there is a separate instance for each binary value returned. If driver uses ByteArrayInputStream, then it can return true. Return true if you support this. extraInfo is always null.

RIGHT_TRIM_STRINGS

  public static final int RIGHT_TRIM_STRINGS = 1
This modifier instructs an adaptable JDBC driver to create String instances with white space already trimmed from the end of the String on calls to ResultSet.getString().

SINGLE_INSTANCE_TIME

  public static final int SINGLE_INSTANCE_TIME = 2
This modifier instructs an adaptable JDBC driver to reuse a single instance of a Java Time/Date/Timestamp object on calls to ResultSet.getDate(), ResultSet.getTime() and ResultSet.getTimestamp().

SQLAdapter methods

adapt(int, java.lang.Object)

  public boolean adapt(int modifier, Object extraInfo)
Adapt the JDBC object which implements this interface to the modification described by one of the above modifiers. This method returns true if the modifier is supported, false otherwise. It throws an SQLException if the driver is unable to adapt to the modification.

Parameters:

modifier
Either RIGHT_TRIM_STRINGS or SINGLE_INSTANCE_TIME
extraInfo
Extra information that needs to be specified along with the modifier.

revert(int)

  public void revert(int modifier)
Revert back to the default JDBC behavior for the object previously adapted for the modification described by the given modifier. This method throws an SQLException if the driver is unable to revert the modification back to the standard JDBC behavior.

Parameters:

modifier
Either RIGHT_TRIM_STRINGS or SINGLE_INSTANCE_TIME