|Oracle9i JDBC Developer's Guide and Reference
Release 2 (9.2)
Part Number A96654-01
Oracle JDBC supports JDBC 2.0 functionality and standardizes functionality that was previously supported through Oracle extensions.
This chapter provides an overview of JDBC 2.0 support in the Oracle JDBC drivers, focusing in particular on any differences in support between the JDK 1.2.x and JDK 1.1.x environments. The following topics are discussed:
The Oracle JDBC drivers are compliant with the JDBC 2.0 specification. JDBC 2.0 functionality previously implemented through Oracle extensions in the
oracle.jdbc2 package--such as structured objects, object references, arrays, and LOBs--is now implemented through the standard
java.sql package in JDK 1.2.
In a JDK 1.1.x environment, you can continue to use the
oracle.jdbc2 package. You can also use JDBC 2.0 features in connection objects, statement objects, result set objects, and database meta data objects under JDK 1.1.x by casting your objects to the Oracle types.
Furthermore, you can use features of the JDBC 2.0 Optional Package (also known as the JDBC 2.0 Standard Extension API) under either JDK 1.2.x or JDK 1.1.x. These features, including connection pooling and distributed transactions, are supported through the standard
javax.sql package. This package and the classes that implement its interfaces are now included with the JDBC classes ZIP file for either JDK 1.2.x or JDK 1.1.x.
Support for standard JDBC 2.0 features differs depending on whether you are using JDK 1.2.x or JDK 1.1.x. There are three areas to consider:
java.sqlpackage under JDK 1.2.x and through the Oracle extension
oracle.jdbc2package under JDK 1.1.x
PreparedStatementunder JDK 1.2.x, but requires Oracle-specific functionality under JDK 1.1.x
This section also discusses performance enhancements available under JDBC 2.0--update batching and fetch size--that are also still available as Oracle extensions, then concludes with a brief discussion about migration from JDK 1.1.x to JDK 1.2.x.
Oracle JDBC fully supports JDK 1.2.x, which includes standard JDBC 2.0 functionality through implementation of interfaces in the standard
java.sql package. These interfaces are implemented as appropriate by classes in the
For JDBC 2.0 functionality under JDK 1.2.x, where you are using
classes12.zip, no special imports are required. The following imports, both of which you will likely need even if you are not using JDBC 2.0 features, will suffice:
JDBC 2.0 features are not supported by JDK 1.1.x; however, Oracle provides extensions that allow you to use a significant subset of JDBC 2.0 datatypes under JDK 1.1.x, where you are using
classes111.zip. These extensions support database objects, object references, arrays, and LOBs.
oracle.jdbc2 is included in
classes111.zip. This package provides interfaces that mimic JDBC 2.0-related interfaces that became standard with JDK 1.2.x for SQL3 and advanced datatypes. The interfaces in
oracle.jdbc2 are implemented as appropriate by classes in the
oracle.sql package for a JDK 1.1.x environment.
The following imports are required for JDBC 2.0 datatypes under JDK 1.1.x:
In a JDK 1.2.x environment (using the JDBC classes in
classes12.zip), JDBC 2.0 features such as scrollable result sets, updatable result sets, and update batching are supported through methods specified by standard JDBC 2.0 interfaces. Therefore, under JDK 1.2.x, you can use standard objects such as
ResultSet to use these features.
In a JDK 1.1.x environment (using the JDBC classes in
classes111.zip), Oracle JDBC provides support for these JDBC 2.0 features as Oracle extensions. To use this functionality, you must cast your objects to the Oracle types:
For example, to use JDBC 2.0 result set enhancements, you must do the following:
OracleConnectionwhenever the connection object will be required to produce a statement object that will in turn produce a scrollable or updatable result set.
In addition, you might have to cast statement objects to
OracleCallableStatement, and cast database meta data objects to
OracleDatabaseMetaData. This would be if you want to use JDBC 2.0 statement or database meta data methods described under "Summary of New Methods for Result Set Enhancements".
Features of the JDBC 2.0 Optional Package (also known as the Standard Extension API), including data sources, connection pooling, and distributed transactions, are supported equally in a JDK 1.2.x or 1.1.x environment.
javax.sql package and classes that implement its interfaces are included in the JDBC classes ZIP file for either environment.
There are two performance enhancements available under JDBC 2.0, which had previously been available as Oracle extensions:
In each case, you have the option of using the standard model or the Oracle model. Do not, however, try to mix usage of the standard model and Oracle model within a single application for either of these features.
For more information, see the following sections:
The only migration requirements in going from JDK 1.1.x to JDK 1.2.x are as follows:
oracle.jdbc2package, as discussed above under "Datatype Support".
oracle.jdbc2.*interfaces with references to the standard
java.util.Dictionaryclass under JDK 1.1.x, must implement the
java.util.Mapinterface under JDK 1.2.x. Note, however, that the class
java.util.Hashtablesatisfies either requirement. If you used
Hashtableobjects for your type maps under JDK 1.1.x, then no change is necessary. For more information, see "Creating a Type Map Object and Defining Mappings for a SQLData Implementation".
If these points do not apply to your code, then you do not need to make any code changes or recompile to run under JDK 1.2.x.
Table 4-1 lists key areas of JDBC 2.0 functionality and points to where you can go in this manual for more information about Oracle support.
|Feature||Comments and References|
See "Update Batching" for information.
result set enhancements (scrollable and updatable result sets)
See Chapter 13, "Result Set Enhancements" for information.
fetch size / row prefetching
use of JNDI (Java Naming and Directory Interface) to specify and obtain database connections
connection pooling (framework for connection caching)
See "Connection Pooling" for information.
connection caching (sample Oracle implementation)
See "Connection Caching" for information..
distributed transactions / XA functionality
See Chapter 15, "Distributed Transactions" for information.
miscellaneous getXXX() methods
See "Other getXXX() Methods" for information about which getXXX() methods are Oracle extensions under JDK 1.2.x and 1.1.x, and about any differences in functionality with JDBC 2.0.
miscellaneous setXXX() methods
See "Other setXXX() Methods" for information about which setXXX() methods are Oracle extensions under JDK 1.2.x and 1.1.x, and about any differences in functionality with JDBC 2.0.
The Oracle JDBC drivers do not support the