Oracle8i JDBC Developer's Guide and Reference Release 3 (8.1.7) Part Number A83724-01 |
Library | Service | Contents | Index

## JDBC 2.0 Support: JDK 1.2.x versus 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:

- datatype support--such as for objects, arrays, and LOBs--which is handled through the standard `java.sql` package under JDK 1.2.x and through the Oracle extension `oracle.jdbc2` package under JDK 1.1.x

- standard feature support--such as result set enhancements and update batching--which is handled through standard objects such as `Connection`, `ResultSet`, and `PreparedStatement` under JDK 1.2.x, but requires Oracle-specific functionality under JDK 1.1.x

- extended feature support--features of the JDBC 2.0 Optional Package (also known as the Standard Extension API), including data sources, connection pooling, and distributed transactions--which, with release 8.1.6 and higher, has the same support and functionality in either JDK 1.2.x or 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.

### Datatype Support

Oracle JDBC release 8.1.6 and higher 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 `oracle.sql` and `oracle.jdbc.driver` packages.

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:

    import java.sql.*;
    import oracle.sql.*;

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.

The package `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:

    import java.sql.*;
    import oracle.jdbc2.*;
    import oracle.sql.*;

### Standard Feature Support

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 `Connection`, `DatabaseMetaData`, `ResultSetMetaData`, `Statement`, `PreparedStatement`, `CallableStatement`, and `ResultSet` to use these features.

With release 8.1.6 and higher 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:

- `OracleConnection`

- `OracleDatabaseMetaData`

- `OracleResultSetMetaData`

- `OracleStatement`

- `OraclePreparedStatement`

- `OracleCallableStatement`

- `OracleResultSet`

For example, to use JDBC 2.0 result set enhancements, you must do the following:

- Explicitly type or cast scrollable or updatable result sets as type `OracleResultSet`.

- Explicitly type or cast connection objects as type `OracleConnection` whenever 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 `OracleStatement`, `OraclePreparedStatement`, or `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".

### Extended Feature Support

With release 8.1.6 and higher, 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.

The standard `javax.sql` package and classes that implement its interfaces are included in the JDBC classes ZIP file for either environment.

### Standard versus Oracle Performance Enhancement APIs

There are two performance enhancements available under JDBC 2.0, which had previously been available as Oracle extensions:

- update batching

- fetch size / row prefetching

In each case, with release 8.1.6 and higher 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:

- "Update Batching"

- "Fetch Size"

- "Oracle Row Prefetching"

### Migration from JDK 1.1.x to JDK 1.2.x

The only migration requirements in going from JDK 1.1.x to JDK 1.2.x are as follows:

- Remove your imports of the `oracle.jdbc2` package, as discussed above under "Datatype Support".

- Replace any direct references to `oracle.jdbc2.*` interfaces with references to the standard `java.sql.*` interfaces.

- Type map objects (for mapping SQL structured objects to Java types), which must extend the `java.util.Dictionary` class under JDK 1.1.x, must implement the `java.util.Map` interface under JDK 1.2.x. Note, however, that the class `java.util.Hashtable` satisfies either requirement. If you used `Hashtable` objects 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.

| Copyright © 1996-2000, Oracle Corporation. All Rights Reserved. |
Library | Service | Contents | Index