Oracle8i SQLJ Developer's Guide and Reference Release 8.1.5 A64684-01 |
|
Oracle's implementation of JDBC supports versions 1.0.2 and 1.1.x of the Sun Microsystems JDK and complies with JDBC 1.22, included with these JDK versions. This chapter describes Oracle extensions to JDBC 1.22, organized into two categories:
This section describes how Oracle JDBC supports these extensions, including the Java packages created and the datatype support issues that must be considered.
Oracle release 8.1.5 does not support JDK 1.2. The JDBC 2.0 interfaces are part of the java.sql
package that is included with the JDK 1.2. Therefore, to support JDBC 2.0 types, as well as additional Oracle extensions, the Oracle JDBC distribution includes the following Java packages:
oracle.jdbc2
(a subset of the standard JDBC 2.0 interfaces)
oracle.sql
(classes to support all Oracle type extensions)
oracle.jdbc.driver
(classes to support database access and updates in Oracle type formats)
"Oracle JDBC Packages and Classes" further describes these packages and their classes.
A key feature of the Oracle JDBC extensions is the type support in the oracle.sql.*
package. This package includes classes that map to all of the Oracle SQL datatypes, acting as wrappers for raw SQL data. This functionality provides two significant advantages in manipulating SQL data:
Once manipulations are complete and it is time to output the information, each of the oracle.sql.*
type support classes has all of the necessary methods to convert data to appropriate Java formats.
For a more detailed description of these general issues, see "Classes of the oracle.sql Package".
Specific information relating to particular oracle.sql.*
datatype classes is discussed in the sections "Working with LOBs" and "Additional Type Extensions".
Perhaps the most noteworthy Oracle8 type is Oracle objects. Oracle8 supports the use of structured objects in the database, where an object datatype is a user-defined type with nested attributes. For example, a user application could define an Employee
object type, where each Employee
object has a firstname
attribute (a character string), a lastname
attribute (another character string), and an employeenumber
attribute (integer).
Oracle's JDBC implementation supports Oracle object datatypes. When you work with Oracle object datatypes in a Java application you must consider the following:
oracle.sql.*
format)
To manually create Java classes to correspond to your Oracle objects, Oracle recommends that you use the Oracle8i JPublisher utility to create the classes. To do this, you must define attributes according to how you want to store the data. JPublisher handles this task seamlessly with command-line options.
A type map defines the correspondence between Oracle object datatypes and Java classes. Type maps are objects of a special Java class that specify which Java class corresponds to each Oracle object datatype. Oracle JDBC uses these type maps to determine which Java class to instantiate and populate when it retrieves Oracle object data from a result set.
Each Java class created to correspond to an Oracle object datatype must implement one of two supported interfaces: the JDBC-standard SQLData
interface or the Oracle CustomDatum
interface. Each of these interfaces specifies methods to convert data between SQL and Java. Currently, JPublisher supports only the CustomDatum
interface.
JPublisher automatically defines get
methods of the Java classes, which retrieve data into your Java application. For more information on the JPublisher utility, see the Oracle8i JPublisher User's Guide.
"Working with Oracle Object Types" describes Oracle JDBC support for Oracle objects.
Oracle JDBC classes have the ability to accept and return fully qualified schema names. A fully qualified schema name has this syntax:
{[schema_name
].}[sql_type_name
]
where schema_name
is the name of the schema and sql_type_name
is the SQL type name of the object. Notice that the schema_name
and the sql_type_name
is separated by a dot (".").
To specify an object type in JDBC, you use its fully qualified name (that is, a schema name and SQL type name). It is not necessary to enter a schema name if the type name is in current naming space (that is, the current schema). Schema naming follows these rules:
CORPORATE.EMPLOYEE
, the type name must be quoted.
For example, assume that user Scott creates a type called person.address
and then wants to use it in his session. Scott might want to skip the schema name and pass in person.address
to the JDBC driver. In this case, if person.address
is not quoted, then the dot will be detected, and the JDBC driver will mistakenly interpret person
as the schema name and address
as the type name.
For example, if ScOtT.PersonType
is passed to the JDBC driver as an object type name, the JDBC driver will pass the string to the database unchanged. As another example, if there is white space between characters in the type name string, then the JDBC driver will not remove the white space.