• Non ci sono risultati.

Class oracle.jdbc.OracleDriver

Use this class to register the Oracle JDBC drivers for use by your application. You can input a new instance of this class to the static registerDriver() method of the java.sql.DriverManager class so that your application can access and use the Oracle drivers. The registerDriver() method takes as input a "driver" class, OracleCallableStatement Interface getXXX() methods to retrieve data in

oracle.sql format; setXXX() methods to bind oracle.sql.* types into a callable statement (implements java.sql.CallableStatement; extends

OraclePreparedStatement) OracleResultSet Interface getXXX() methods to retrieve data in

oracle.sql format (implements java.sql.ResultSet)

OracleResultSetMetaData Interface methods to get meta information about Oracle result sets, such as column names and datatypes (implements

java.sql.ResultSetMetaData) OracleDatabaseMetaData Class methods to get meta information about the database, such as database product name/version, table information, and default transaction isolation level (implements

java.sql.DatabaseMetaData) OracleTypes Class defines integer constants used to identify

SQL types. For standard types, it uses the same values as the standard

java.sql.Types class. In addition, it adds constants for Oracle extended types.

Table 5–2 Key Interfaces and Classes of the oracle.jdbc Package (Cont.)

Name

Interface

or Class Key Functionality

Oracle JDBC Packages and Classes

that is, a class that implements the java.sql.Driver interface, as is the case with OracleDriver.

Once you register the Oracle JDBC drivers, you can create your connection using the DriverManager class. For more information on registering drivers and writing a connection string, see "First Steps in JDBC" on page 3-2.

Interface oracle.jdbc.OracleConnection

This interface extends standard JDBC connection functionality to create and return Oracle statement objects, set flags and options for Oracle performance extensions, and support type maps for Oracle objects.

"Additional Oracle Performance Extensions" on page 12-20 describes the

performance extensions, including row prefetching, update batching, and metadata TABLE_REMARKS reporting.

Key methods include:

createStatement(): Allocates a new OracleStatement object.

prepareStatement(): Allocates a new OraclePreparedStatement object.

prepareCall(): Allocates a new OracleCallableStatement object.

getTypeMap(): Retrieves the type map for this connection (for use in mapping Oracle object types to Java classes).

setTypeMap(): Initializes or updates the type map for this connection (for use in mapping Oracle object types to Java classes).

getTransactionIsolation(): Gets this connection’s current isolation mode.

setTransactionIsolation(): Changes the transaction isolation level using one of the TRANSACTION_* values.

These oracle.jdbc.OracleConnection methods are Oracle-defined extensions:

getDefaultExecuteBatch(): Retrieves the default update-batching value for this connection.

setDefaultExecuteBatch(): Sets the default update-batching value for this connection.

getDefaultRowPrefetch(): Retrieves the default row-prefetch value for this connection.

setDefaultRowPrefetch(): Sets the default row-prefetch value for this connection.

getRemarksReporting(): Returns true if TABLE_REMARKS reporting is enabled.

setRemarksReporting(): Enables or disables TABLE_REMARKS reporting.

Interface oracle.jdbc.OracleStatement

This interface extends standard JDBC statement functionality and is the superinterface of the OraclePreparedStatement and

OracleCallableStatement classes. Extended functionality includes support for setting flags and options for Oracle performance extensions on a

statement-by-statement basis, as opposed to the OracleConnection interface that sets these on a connection-wide basis.

"Additional Oracle Performance Extensions" on page 12-20 describes the

performance extensions, including row prefetching and column type definitions.

Key methods include:

executeQuery(): Executes a database query and returns an OracleResultSet object.

getResultSet(): Retrieves an OracleResultSet object.

close(): Closes the current statement.

These oracle.jdbc.OracleStatement methods are Oracle-defined extensions:

defineColumnType(): Defines the type you will use to retrieve data from a particular database table column.

getRowPrefetch(): Retrieves the row-prefetch value for this statement.

setRowPrefetch(): Sets the row-prefetch value for this statement.

Interface oracle.jdbc.OraclePreparedStatement

This interface extends the OracleStatement interface and extends standard JDBC prepared statement functionality. Also, the

oracle.jdbc.OraclePreparedStatement interface is extended by the OracleCallableStatement interface. Extended functionality consists of setXXX() methods for binding oracle.sql.* types and objects into prepared statements, and methods to support Oracle performance extensions on a

statement-by-statement basis.

Oracle JDBC Packages and Classes

"Additional Oracle Performance Extensions" on page 12-20 describes the performance extensions, including database update batching.

Key methods include:

getExecuteBatch(): Retrieves the update-batching value for this statement.

setExecuteBatch(): Sets the update-batching value for this statement.

setOracleObject(): This is a generic setXXX() method for binding oracle.sql.* data into a prepared statement as an oracle.sql.Datum object.

setXXX(): These methods, such as setBLOB(), are for binding specific oracle.sql.* types into prepared statements.

setORAData(): Binds an ORAData object (for use in mapping Oracle object types to Java) into a prepared statement.

setNull(): Sets the value of the object specified by its SQL type name to NULL. For setNull(param_index, type_code, sql_type_name), if type_

code is REF, ARRAY, or STRUCT, then sql_type_name is the fully qualified name (schema.sql_type_name) of the SQL type.

setFormOfUse(): Sets which form of use this method is going to use. There are two constants that specify the form of use: FORM_CHAR and FORM_NCHAR, where FORM_CHAR is the default. If the form of use is set to FORM_NCHAR, the JDBC driver will represent the provided data in the national character set of the server. The following code show how the FORM_NCHAR is used:

pstmt.setFormOfUse (parameter index,

oracle.jdbc.OraclePreparedStatement.FORM_NCHAR)

close(): Closes the current statement.

Interface oracle.jdbc.OracleCallableStatement

This interface extends the OraclePreparedStatement interface (which extends the OracleStatement interface) and incorporates standard JDBC callable statement functionality.

Key methods include:

getOracleObject(): This is a generic getXXX() method for retrieving data into an oracle.sql.Datum object, which can be cast to the specific

oracle.sql.* type as necessary.

getXXX(): These methods, such as getCLOB(), are for retrieving data into specific oracle.sql.* objects.

setOracleObject(): This is a generic setXXX() method for binding oracle.sql.* data into a callable statement as an oracle.sql.Datum object.

setXXX(): These methods, such as setBLOB(), are inherited from

OraclePreparedStatement for binding specific oracle.sql.* objects into callable statements.

setNull(): Sets the value of the object specified by its SQL type name to NULL. For setNull(param_index, type_code, sql_type_name), if type_

code is REF, ARRAY, or STRUCT, then sql_type_name is the fully qualified (schema.type) name of the SQL type.

setFormOfUse(): Sets which form of use this method is going to use. There are two constants that specify the form of use: FORM_CHAR and FORM_NCHAR, where FORM_CHAR is the default. If the form of use is set to FORM_NCHAR, the JDBC driver will represent the provided data in the national character set of the server. The following code show how the FORM_NCHAR is used:

pstmt.setFormOfUse (parameter index,

oracle.jdbc.OraclePreparedStatement.FORM_NCHAR)

registerOutParameter(): Registers the SQL typecode of the statement’s output parameter. JDBC requires this for any callable statement with an OUT parameter. It takes an integer parameter index (the position of the output variable in the statement, relative to the other parameters) and an integer SQL type (the type constant defined in oracle.jdbc.OracleTypes).

This is an overloaded method. One version of this method is for named types only—when the SQL typecode is OracleTypes.REF, STRUCT, or ARRAY. In this case, in addition to a parameter index and SQL type, the method also takes a String SQL type name (the name of the Oracle user-defined type in the database, such as EMPLOYEE).

close(): Closes the current result set, if any, and the current statement.

Interface oracle.jdbc.OracleResultSet

This interface extends standard JDBC result set functionality, implementing getXXX() methods for retrieving data into oracle.sql.* objects.

Key methods include:

Oracle JDBC Packages and Classes

getOracleObject(): This is a generic getXXX() method for retrieving data into an oracle.sql.Datum object. It can be cast to the specific

oracle.sql.* type as necessary.

getXXX(): These methods, such as getCLOB(), are for retrieving data into oracle.sql.* objects.

Interface oracle.jdbc.OracleResultSetMetaData

This interface extends standard JDBC result set metadata functionality to retrieve information about Oracle result set objects. See "Using Result Set Meta Data Extensions" on page 6-19 for information on the functionality of the

OracleResultSetMetadata interface.

Documenti correlati