Key JDBC Classes and Interfaces
There is support for standard and TimesTen-specific JDBC packages, classes, and interfaces.
The following topics are covered:
For reference information on standard JDBC, see the following for information about the java.sql
and javax.sql
packages:
https://docs.oracle.com/javase/8/docs/api/java/sql/package-summary.html
https://docs.oracle.com/javase/8/docs/api/javax/sql/package-summary.html
For reference information on TimesTen JDBC extensions, refer to Oracle TimesTen In-Memory Database JDBC Extensions Java API Reference.
Note:
TimesTen supports Java 8 APIs (JDBC 4.2).
Package Imports
You will need to import some JDBC packages for your application.
Import the standard JDBC package in any Java program that uses JDBC:
import java.sql.*;
If you are going to use data sources or pooled connections, also import the standard extended JDBC package:
import javax.sql.*;
Import the TimesTen JDBC package:
import com.timesten.jdbc.*;
To use XA data sources for JTA, also import this TimesTen package:
import com.timesten.jdbc.xa.*;
Support for Interfaces in the java.sql Package
TimesTen supports the java.sql
interfaces.
The supported interfaces are indicated in Table 2-1, with TimesTen-specific support and restrictions noted.
Also see TimesTen JDBC Extensions.
Table 2-1 Supported java.sql Interfaces
Interface in java.sql | Remarks on TimesTen Support |
---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Support for Classes in the java.sql Package
TimesTen supports certain java.sql
classes (and some additional subclasses of SQLException
).
Table 2-2 Supported java.sql Classes
Interface in java.sql | Remarks on TimesTen Support |
---|---|
|
No remarks |
|
No remarks |
|
No remarks |
|
No remarks |
|
Because TimesTen does not support |
|
Same consideration for |
|
No remarks |
|
No remarks |
|
No remarks |
|
No remarks |
Support Notes for Classes in the java.io Package
There are special notes for TimesTen support of classes in the java.io
package.
-
An
InputStream
object returned by TimesTen does not support mark or reset operations (specifically, themark()
,markSupported()
, andreset()
methods). -
The
read()
method of anInputStream
orReader
object returns 0 (zero) if the length of the buffer used in the method call is 0, regardless of the amount of data in theInputStream
orReader
object. Therefore, usage such as the following is problematic if the CLOB length may be 0, such as if it were populated using the SQLEMPTY_CLOB()
function:java.io.Reader r = myclob.getCharacterStream(); char[] buf = new char[myclob.length()]; //buf for r.read() call
Typically, when you call
read()
, -1 is returned if the end of the stream is reached. But in the preceding case, -1 is never returned. Be aware of this when you use streams returned by the BLOBgetBinaryStream()
method, which returnsInputStream
, the CLOBgetAsciiStream()
method, which returnsInputStream
, or the CLOBgetCharacterStream()
method, which returnsReader
.
Support for Interfaces and Classes in the javax.sql Package
TimesTen supports certain javax.sql
interfaces.
-
CommonDataSource
andDataSource
are implemented byTimesTenDataSource
.TimesTen does not use
java.util.logging
, so thegetParentLogger()
method, specified inCommonDataSource
, returnsSQLFeatureNotSupportedException
. (The TimesTen driver precededjava.util.logging
functionality and uses its own logging mechanism.) -
PooledConnection
is implemented byObservableConnection
. -
ConnectionPoolDataSource
is implemented byObservableConnectionDS
. -
XADataSource
is implemented byTimesTenXADataSource
(in packagecom.timesten.jdbc.xa
).
Note:
The TimesTen JDBC driver itself does not implement a database connection pool. The ObservableConnection
and ObservableConnectionDS
classes simply implement standard Java EE interfaces, facilitating the creation and management of database connection pools according to the Java EE standard.
TimesTen supports this javax.sql
event listener:
-
When using a
PooledConnection
instance, you can register aConnectionEventListener
instance to listen forConnectionEvent
occurrences.
Note:
You can register a StatementEventListener
instance in TimesTen; however, StatementEvent
instances are not supported.
TimesTen JDBC Extensions
For most scenarios, you can use standard JDBC functionality as supported by TimesTen, but TimesTen also provides extensions in the com.timesten.jdbc
package for TimesTen-specific features.
This is shown in Table 2-3.
Table 2-3 TimesTen JDBC Extensions
Interface | Extends | Remarks |
---|---|---|
|
|
You can cast See Large Objects (LOBs). |
|
|
Exposed through Supports PL/SQL REF CURSORs. See Working with REF CURSORs. Supports associative array binds with methods to set input parameters and to register and get output parameters. See Working with Associative Arrays. |
|
|
You can cast See Large Objects (LOBs). |
|
|
Exposed through Provides capabilities such as prefetching rows to improve performance, optimizing query performance, listening to events for automatic client failover, setting the track number for parallel replication schemes where you specify replication tracks, checking database validity, and setting the maximum number of rows or bytes for the client/server result set buffer. See Fetching Multiple Rows of Data, Optimizing Query Performance, General Client Failover Features, Features for Use with Replication, Checking Database Validity and Configuring the Result Set Buffer Size in Client/Server Using JDBC. |
|
|
You can cast See Large Objects (LOBs). |
|
|
Exposed through Supports DML returning. See Working with DML Returning (RETURNING INTO Clause). Supports associative array binds with a method to set input parameters. See Working with Associative Arrays. |
|
|
Exposed through Provides capabilities for specifying a query threshold or setting or getting the maximum number of rows or bytes for the client/server result set buffer. See Setting a Threshold Duration for SQL Statements and Configuring the Result Set Buffer Size in Client/Server Using JDBC. |
Additional TimesTen Classes and Interfaces
In addition to implementations discussed previously, TimesTen provides interfaces and classes in the com.timesten.jdbc
package.
Features supported by these interfaces and classes are discussed later in this chapter.
-
Use interface
TimesTenTypes
for TimesTen type extensions (such as for TimesTen REF CURSORs). -
Use interface
ClientFailoverEventListener
(and also theClientFailoverEvent
class below) for automatic client failover features. See JDBC Support for Automatic Client Failover. -
Use interface
TimesTenVendorCode
for vendor codes used in SQL exceptions. -
Use interface
TimesTenDistributionKey
andTimesTenDistributionKeyBuilder
for client routing in TimesTen Scaleout. See Client Routing API for TimesTen Scaleout. -
Use interface
TimesTenConnectionBuilder
to connect to an optimal element based on a distribution key, element ID, or replica set ID. See Connecting to an Element Based on a Distribution Key. -
Use class
ClientFailoverEvent
(and also theClientFailoverEventListener
interface above) for automatic client failover features.