|
Oracle JDBC API Reference 12c Release 1 ("12.1.0.2.0") E17663-03 |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
public interface OracleStatement
This interface defines the Oracle extensions to the standard JDBC interface
java.sql.Statement and is the superinterface of the
OraclePreparedStatement and OracleCallableStatement
interfaces. You can use java.sql.Statement in your application
where you do not make use of the Oracle extensions. However, when your
application uses the Oracle extensions to java.sql.Statement you
must cast your statement object to the type
oracle.jdbc.OracleStatement. Although the type by which the java
compiler will identify the statement object is changed, the object itself is
unchanged.
Extended functionality includes support for settings flags and options for
Oracle performance extensions on a statement-by-statements basis, as opposed
to the OracleConnection interface that sets these on a
connection-wide basis.
Connection.createStatement| Field Summary | |
|---|---|
static int |
EXPLICIT
|
static int |
IMPLICIT
|
static int |
NEW
|
| Fields inherited from interface java.sql.Statement |
|---|
CLOSE_ALL_RESULTS, CLOSE_CURRENT_RESULT, EXECUTE_FAILED, KEEP_CURRENT_RESULT, NO_GENERATED_KEYS, RETURN_GENERATED_KEYS, SUCCESS_NO_INFO |
| Method Summary | |
|---|---|
void |
clearDefines()
Lets you clear previously defined types for the define-columns of this statement. |
void |
closeWithKey(String key)
The underlying cursor is not closed and the Statement handle is cached on the Key. |
int |
creationState()
Deprecated. |
void |
defineColumnType(int columnIndex,
int type)
Defines the type you will use to retrieve data from a particular database table column. |
void |
defineColumnType(int columnIndex,
int type,
int lobPrefetchSize)
Defines the type you will use to retrieve data from a particular database table column. |
void |
defineColumnType(int columnIndex,
int type,
int lobPrefetchSize,
short formOfUse)
Deprecated. |
void |
defineColumnType(int columnIndex,
int typeCode,
String typeName)
Defines the type you will use to retrieve data from a particular database table column and specifies the column type name. |
void |
defineColumnTypeBytes(int columnIndex,
int type,
int lobPrefetchSize)
Deprecated. |
void |
defineColumnTypeChars(int columnIndex,
int type,
int lobPrefetchSize)
Deprecated. |
int |
getLobPrefetchSize()
Returns the LOB prefetch size. |
long |
getRegisteredQueryId()
Returns the id of the query that has been added in the registration (only for query change notification). |
String[] |
getRegisteredTableNames()
Returns the name of the tables that have been added to the registration if any. |
int |
getRowPrefetch()
Retrieves the value or row prefetch for all result sets created from this statement. |
boolean |
isNCHAR(int index)
isNCHAR (int) |
void |
setDatabaseChangeRegistration(DatabaseChangeRegistration registration)
Associate a Database Change Registration object with this statement. |
void |
setLobPrefetchSize(int value)
Overrides the LOB prefetch size for this statement. |
void |
setRowPrefetch(int value)
Sets the value of row prefetch for all result sets created from this statement. |
| Methods inherited from interface java.sql.Wrapper |
|---|
isWrapperFor, unwrap |
| Field Detail |
|---|
static final int NEW
static final int IMPLICIT
static final int EXPLICIT
| Method Detail |
|---|
void clearDefines()
throws SQLException
After calling clearDefines, you can either perform defines
by calling defineColumnType/defineColumnTypeChars or let the
driver use the default defines for the table.
SQLException - if an error occurs
void defineColumnType(int columnIndex,
int type)
throws SQLException
Defines the type you will use to retrieve data from a particular database table column.
For the JDBC-OCI driver and the server-side internal driver, if you decide to use defineColumnType you must declare the types of exactly all columns in the query. For the thin driver, it is not required to define all the columns.
See the JDBC Manual section on Data Interface for LOBs for a description of using defineColumnType to get LOB columns as streams. In some cases this is a large performance gain. The lob prefetch feature makes this less important, however. It is effective for basic lobs, but less so for SecureFile lobs.
BFILE, BLOB, CLOB, or NCLOB data can be read using the same streaming mechanism as for LONG RAW and LONG data. Use defineColumnType(nn, Types.LONGVARBINARY) for BLOB or BFILE, defineColumnType(nn,Types.LONGVARCHAR) for CLOB, or defineColumnType(nn,Types.LONGNVARCHAR) for NCLOB. This produces a stream on the data as if it were a LONG RAW or LONG column. Use defineColumnType( nn, Types.VARBINARY) or defineColumnType(nn, Types.VARCHAR) returns the data as if it were a RAW or VARCHAR2 column with the size limits of those types.
The following example illustrates the use of this feature in the PM sample schema:
// Ask for the column as a character stream:
((OracleStatement)stmt).defineColumnType(1, Types.LONGVARCHAR);
ResultSet rset = stmt.executeQuery("select PRODUCT_TEXT from ONLINE_MEDIA");
while (rset.next() )
System.out.println(rset.getString(1));
All columns can be defined to their "natural" JDBC types; in most
cases, they can be defined to the Types.CHAR or
Types.VARCHAR typecode. You can also use the
OracleTypes typecodes. The type can also be different from the
native type of the column. Appropriate conversions will be done. A
subsequent call to getObject() for this column will return the
supplied type rather than the native type.
columnIndex - index of column (first is 1)type - type to be assigned to column
SQLException - if an error occursdefineColumnType(int,int,int),
clearDefines
void defineColumnType(int columnIndex,
int type,
int lobPrefetchSize)
throws SQLException
Defines the type you will use to retrieve data from a particular database table column. See defineColumnType( int, int) for general information.
In previous releases the third parameter was used to control the buffer
sizes used with possible truncation of data. In the current release it is
used only to control the LOB prefetch size at the column level.
This setting overrides the default LOB prefetch size that is defined at the
connection or statement level. The lobPrefetchSize argument represents
in this case the number of bytes to prefetch for a BLOB and chars for a CLOB and
the value must be >= 0 and the type must be set to OracleTypes.CLOB for a CLOB
column and OracleTypes.BLOB for a BLOB column.
columnIndex - index of column (first is 1)type - type to be assigned to columnlobPrefetchSize - for lob column, size of prefetch buffer
SQLException#java.sql.Statement.setMaxFieldSize
void defineColumnType(int columnIndex,
int type,
int lobPrefetchSize,
short formOfUse)
throws SQLException
Deprecated method, please use defineColumnType(int, int, int) with the type such as Types.NCHAR, Types.NVARCHAR, Types.NCLOB.
See defineColumnType( int, int) for general information.
The formOfUse parameter may take the value oracle.jdbc.OraclePreparedStatement.FORM_CHAR to specify that the data be in the database character set or oracle.jdbc.OraclePreparedStatement.FORM_NCHAR to specify that the data be in the national character set.
columnIndex - index of column (first is 1)type - type to be assigned to columnlobPrefetchSize - for lob column, size of prefetch bufferformOfUse - flag to select character set.
SQLException
void defineColumnTypeBytes(int columnIndex,
int type,
int lobPrefetchSize)
throws SQLException
columnIndex - index of column (first is 1)type - type to be assigned to columnlobPrefetchSize - ignored except for lob columns
SQLException - if an error occursdefineColumnType(int,int,int),
clearDefines
void defineColumnTypeChars(int columnIndex,
int type,
int lobPrefetchSize)
throws SQLException
columnIndex - index of column (first is 1)type - type to be assigned to columnlobPrefetchSize - ignored except for lob columns
SQLException - if an error occursdefineColumnType(int,int,int),
clearDefines
void defineColumnType(int columnIndex,
int typeCode,
String typeName)
throws SQLException
Defines the type you will use to retrieve data from a particular database table column and specifies the column type name. This method should be used for structured object, object reference and array columns. See defineColumnType( int, int) for general information.
columnIndex - index of column (first is 1)typeCode - type code for this column.typeName - specifies the fully-qualified name of the
type of the column
SQLException - if an error occursdefineColumnType(int,int),
clearDefinesint getRowPrefetch()
The row-prefetching feature associates an integer row-prefetch setting
with a given statement object. JDBC fetches that number of rows at a time
from the database during the query. That is, JDBC will fetch N rows that
match the query criteria and bring them all back to the client at once,
where N is the prefetch setting. Then, once your next calls
have run through those N rows, JDBC will go back to fetch the next N rows
that match the criteria.
You can set the number of rows to prefetch for this particular Oracle
statement (any type of statement). You can also reset the default number of
rows that will be prefetched for all statements in your connection with the
OracleConnection.setDefaultRowPrefetch method.
setRowPrefetch,
OracleConnection.setDefaultRowPrefetch
void setRowPrefetch(int value)
throws SQLException
The row-prefetching feature associates an integer row-prefetch setting
with a given statement object. JDBC fetches that number of rows at a time
from the database during the query. That is, JDBC will fetch N rows that
match the query criteria and bring them all back to the client at once,
where N is the prefetch setting. Then, once your next calls
have run through those N rows, JDBC will go back to fetch the next N rows
that match the criteria.
The row_prefetch will be turned back to 1 automatically by the driver if any of the select-column types is streaming (long data or long raw data). This is overrides any value the user might set. Also, this will be done regardless of wether the streaming columns are read or not.
Notes :
value - the number of rows to prefetch
SQLException - if the argument value is <=0getRowPrefetch,
OracleConnection.setDefaultRowPrefetch
int getLobPrefetchSize()
throws SQLException
oracle.jdbc.defaultLobPrefetchSize connection
property or at the statement level through the setLobPrefetchSize(int)
method.
SQLExceptionsetLobPrefetchSize
void setLobPrefetchSize(int value)
throws SQLException
LOB prefetch is enabled by default (see the oracle.jdbc.defaultLobPrefetchSize connection
property which default value is 4k bytes for BLOBs and 4k chars for CLOBs). The LOB prefetch
size can be set at the connection level through the property or at the statement level through
this method. The statement level setting overrides the setting at the connection level. This
setting can also be overriden at the column level through the defineColumnType method
where the size represents the number of bytes (or chars for CLOB) to prefetch.
value - must be >= -1. -1 disables the feature. 0 enables LOB prefetch of meta data
only (lob length and chunk size). Any value >=0 represents the number of bytes to be prefetched for
BLOB and the number of chars for CLOB.
SQLException - if value < -1getLobPrefetchSize,
OracleConnection.DEFAULT_LOB_PREFETCH_SIZE
void closeWithKey(String key)
throws SQLException
key - A key to tag to the statement to be retrieved later
SQLException - if a database access error occursint creationState()
boolean isNCHAR(int index)
throws SQLException
index - the column index
SQLException
void setDatabaseChangeRegistration(DatabaseChangeRegistration registration)
throws SQLException
Any subsequent queries executed with this statement will be part of the given registration.
If you want this statement to no longer add queries to the registration, call this method again with a 'null' argument. Subsequent queries won't be part of the registration.
registration - can be either a valid registration or 'null'.
SQLExceptiongetRegisteredQueryId()
String[] getRegisteredTableNames()
throws SQLException
SQLException
long getRegisteredQueryId()
throws SQLException
SQLExceptionsetDatabaseChangeRegistration(oracle.jdbc.dcn.DatabaseChangeRegistration)
|
Oracle JDBC API Reference 12c Release 1 ("12.1.0.2.0") E17663-03 |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||