Package com.sun.gjc.spi.jdbc40
Class StatementWrapper40
- java.lang.Object
-
- com.sun.gjc.spi.base.StatementWrapper
-
- com.sun.gjc.spi.jdbc40.StatementWrapper40
-
- All Implemented Interfaces:
StatementLeakListener,AutoCloseable,Statement,Wrapper
public class StatementWrapper40 extends StatementWrapper
Wrapper for JDBC 4.0 Statement
-
-
Field Summary
Fields Modifier and Type Field Description protected static StringManagerlocalStrings-
Fields inherited from class com.sun.gjc.spi.base.StatementWrapper
_logger, connection, executor, jdbcStatement, leakDetector, resultSetCount
-
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
-
-
Constructor Summary
Constructors Constructor Description StatementWrapper40(Connection con, Statement statement)Creates a new instance of StatementWrapper for JDBC 3.0
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description long[]executeLargeBatch()Submits a batch of commands to the database for execution and if all commands execute successfully, returns an array of update counts.longexecuteLargeUpdate(String sql)Executes the given SQL statement, which may be anINSERT,UPDATE, orDELETEstatement or an SQL statement that returns nothing, such as an SQL DDL statement.longexecuteLargeUpdate(String sql, int autoGeneratedKeys)Executes the given SQL statement and signals the driver with the given flag about whether the auto-generated keys produced by thisStatementobject should be made available for retrieval.longexecuteLargeUpdate(String sql, int[] columnIndexes)Executes the given SQL statement and signals the driver that the auto-generated keys indicated in the given array should be made available for retrieval.longexecuteLargeUpdate(String sql, String[] columnNames)Executes the given SQL statement and signals the driver that the auto-generated keys indicated in the given array should be made available for retrieval.ResultSetexecuteQuery(String sql)Executes the given SQL statement, which returns a singleResultSetobject.ResultSetgetGeneratedKeys()Retrieves any auto-generated keys created as a result of executing thisStatementobject.longgetLargeMaxRows()Retrieves the maximum number of rows that aResultSetobject produced by thisStatementobject can contain.longgetLargeUpdateCount()Retrieves the current result as an update count; if the result is aResultSetobject or there are no more results, -1 is returned.ResultSetgetResultSet()Retrieves the current result as aResultSetobject.booleanisClosed()Retrieves whether thisStatementobject has been closed.booleanisPoolable()Returns a value indicating whether theStatementis poolable or not.booleanisWrapperFor(Class<?> iface)Returns true if this either implements the interface argument or is directly or indirectly a wrapper for an object that does.voidsetLargeMaxRows(long max)Sets the limit for the maximum number of rows that anyResultSetobject generated by thisStatementobject can contain to the given number.voidsetPoolable(boolean poolable)Requests that aStatementbe pooled or not pooled.<T> Tunwrap(Class<T> iface)Returns an object that implements the given interface to allow access to non-standard methods, or standard methods not exposed by the proxy.-
Methods inherited from class com.sun.gjc.spi.base.StatementWrapper
actualCloseOnCompletion, addBatch, cancel, clearBatch, clearWarnings, close, closeOnCompletion, decrementResultSetCount, execute, execute, execute, execute, executeBatch, executeUpdate, executeUpdate, executeUpdate, executeUpdate, getActualConnection, getCloseOnCompletion, getConnection, getFetchDirection, getFetchSize, getMaxFieldSize, getMaxRows, getMoreResults, getMoreResults, getQueryTimeout, getResultSetConcurrency, getResultSetCount, getResultSetHoldability, getResultSetType, getUpdateCount, getWarnings, incrementResultSetCount, isCloseOnCompletion, isMarkedForReclaim, markForReclaim, reclaimStatement, setCursorName, setEscapeProcessing, setFetchDirection, setFetchSize, setMaxFieldSize, setMaxRows, setQueryTimeout
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.sql.Statement
enquoteIdentifier, enquoteLiteral, enquoteNCharLiteral, isSimpleIdentifier
-
-
-
-
Field Detail
-
localStrings
protected static final StringManager localStrings
-
-
Constructor Detail
-
StatementWrapper40
public StatementWrapper40(Connection con, Statement statement)
Creates a new instance of StatementWrapper for JDBC 3.0- Parameters:
con- ConnectionWrapperstatement- Statement that is to be wrapped
-
-
Method Detail
-
isClosed
public boolean isClosed() throws SQLExceptionRetrieves whether thisStatementobject has been closed. AStatementis closed if the method close has been called on it, or if it is automatically closed.- Returns:
- true if this
Statementobject is closed; false if it is still open - Throws:
SQLException- if a database access error occurs- Since:
- 1.6
-
setPoolable
public void setPoolable(boolean poolable) throws SQLExceptionRequests that aStatementbe pooled or not pooled. The value specified is a hint to the statement pool implementation indicating whether the application wants the statement to be pooled. It is up to the statement pool manager as to whether the hint is used.The poolable value of a statement is applicable to both internal statement caches implemented by the driver and external statement caches implemented by application servers and other applications.
By default, aStatementis not poolable when created, and aPreparedStatementandCallableStatementare poolable when created.- Parameters:
poolable- requests that the statement be pooled if true and that the statement not be pooled if false- Throws:
SQLException- if this method is called on a closedStatement- Since:
- 1.6
-
isPoolable
public boolean isPoolable() throws SQLExceptionReturns a value indicating whether theStatementis poolable or not.- Returns:
trueif theStatementis poolable;falseotherwise- Throws:
SQLException- if this method is called on a closedStatement- Since:
- 1.6
- See Also:
Statement.setPoolable(boolean)
-
unwrap
public <T> T unwrap(Class<T> iface) throws SQLException
Returns an object that implements the given interface to allow access to non-standard methods, or standard methods not exposed by the proxy.If the receiver implements the interface then the result is the receiver or a proxy for the receiver. If the receiver is a wrapper and the wrapped object implements the interface then the result is the wrapped object or a proxy for the wrapped object. Otherwise return the the result of calling
unwraprecursively on the wrapped object or a proxy for that result. If the receiver is not a wrapper and does not implement the interface, then anSQLExceptionis thrown.- Parameters:
iface- A Class defining an interface that the result must implement.- Returns:
- an object that implements the interface. May be a proxy for the actual implementing object.
- Throws:
SQLException- If no object found that implements the interface- Since:
- 1.6
-
isWrapperFor
public boolean isWrapperFor(Class<?> iface) throws SQLException
Returns true if this either implements the interface argument or is directly or indirectly a wrapper for an object that does. Returns false otherwise. If this implements the interface then return true, else if this is a wrapper then return the result of recursively callingisWrapperForon the wrapped object. If this does not implement the interface and is not a wrapper, return false. This method should be implemented as a low-cost operation compared tounwrapso that callers can use this method to avoid expensiveunwrapcalls that may fail. If this method returns true then callingunwrapwith the same argument should succeed.- Parameters:
iface- a Class defining an interface.- Returns:
- true if this implements the interface or directly or indirectly wraps an object that does.
- Throws:
SQLException- if an error occurs while determining whether this is a wrapper for an object with the given interface.- Since:
- 1.6
-
getGeneratedKeys
public ResultSet getGeneratedKeys() throws SQLException
Retrieves any auto-generated keys created as a result of executing thisStatementobject. If thisStatementobject did not generate any keys, an emptyResultSetobject is returned.
Note:If the columns which represent the auto-generated keys were not specified, the JDBC driver implementation will determine the columns which best represent the auto-generated keys.- Returns:
- a
ResultSetobject containing the auto-generated key(s) generated by the execution of thisStatementobject - Throws:
SQLException- if a database access error occurs or this method is called on a closedStatementSQLFeatureNotSupportedException- if the JDBC driver does not support this method- Since:
- 1.4
-
getResultSet
public ResultSet getResultSet() throws SQLException
Retrieves the current result as aResultSetobject. This method should be called only once per result.- Returns:
- the current result as a
ResultSetobject ornullif the result is an update count or there are no more results - Throws:
SQLException- if a database access error occurs or this method is called on a closedStatement- See Also:
StatementWrapper.execute(java.lang.String)
-
executeQuery
public ResultSet executeQuery(String sql) throws SQLException
Executes the given SQL statement, which returns a singleResultSetobject.- Parameters:
sql- an SQL statement to be sent to the database, typically a static SQLSELECTstatement- Returns:
- a
ResultSetobject that contains the data produced by the given query; nevernull - Throws:
SQLException- if a database access error occurs, this method is called on a closedStatementor the given SQL statement produces anything other than a singleResultSetobject
-
getLargeUpdateCount
public long getLargeUpdateCount() throws SQLExceptionRetrieves the current result as an update count; if the result is aResultSetobject or there are no more results, -1 is returned.- Returns:
- the current result as an update count; -1 if the current result
is a
ResultSetobject or there are no more results - Throws:
SQLException- if a database access error occurs or this method is called on a closedStatement
-
setLargeMaxRows
public void setLargeMaxRows(long max) throws SQLExceptionSets the limit for the maximum number of rows that anyResultSetobject generated by thisStatementobject can contain to the given number.- Parameters:
max- the new max rows limit; zero means there is no limit- Throws:
SQLException- if a database access error occurs, this method is called on a closedStatementor the conditionmax >= 0is not satisfied
-
getLargeMaxRows
public long getLargeMaxRows() throws SQLExceptionRetrieves the maximum number of rows that aResultSetobject produced by thisStatementobject can contain.- Returns:
- the current maximum number of rows for a
ResultSetobject produced by thisStatementobject; zero means there is no limit - Throws:
SQLException- if a database access error occurs or this method is called on a closedStatement
-
executeLargeBatch
public long[] executeLargeBatch() throws SQLExceptionSubmits a batch of commands to the database for execution and if all commands execute successfully, returns an array of update counts.- Returns:
- an array of update counts containing one element for each command in the batch. The elements of the array are ordered according to the order in which commands were added to the batch.
- Throws:
SQLException- if a database access error occurs, this method is called on a closedStatementor the driver does not support batch statements. ThrowsBatchUpdateException(a subclass ofSQLException) if one of the commands sent to the database fails to execute properly or attempts to return a result set.SQLTimeoutException- when the driver has determined that the timeout value that was specified by thesetQueryTimeoutmethod has been exceeded and has at least attempted to cancel the currently runningStatement
-
executeLargeUpdate
public long executeLargeUpdate(String sql) throws SQLException
Executes the given SQL statement, which may be anINSERT,UPDATE, orDELETEstatement or an SQL statement that returns nothing, such as an SQL DDL statement.- Parameters:
sql- an SQL Data Manipulation Language (DML) statement, such asINSERT,UPDATEorDELETE; or an SQL statement that returns nothing, such as a DDL statement.- Returns:
- either (1) the row count for SQL Data Manipulation Language (DML) statements or (2) 0 for SQL statements that return nothing
- Throws:
SQLException- if a database access error occurs, this method is called on a closedStatement, the given SQL statement produces aResultSetobject, the method is called on aPreparedStatementorCallableStatementSQLTimeoutException- when the driver has determined that the timeout value that was specified by thesetQueryTimeoutmethod has been exceeded and has at least attempted to cancel the currently runningStatement
-
executeLargeUpdate
public long executeLargeUpdate(String sql, int autoGeneratedKeys) throws SQLException
Executes the given SQL statement and signals the driver with the given flag about whether the auto-generated keys produced by thisStatementobject should be made available for retrieval.- Parameters:
sql- an SQL Data Manipulation Language (DML) statement, such asINSERT,UPDATEorDELETE; or an SQL statement that returns nothing, such as a DDL statement.autoGeneratedKeys- a flag indicating whether auto-generated keys should be made available for retrieval; one of the following constants:Statement.RETURN_GENERATED_KEYSStatement.NO_GENERATED_KEYS- Returns:
- either (1) the row count for SQL Data Manipulation Language (DML) statements or (2) 0 for SQL statements that return nothing
- Throws:
SQLException- if a database access error occurs, this method is called on a closedStatement, the given SQL statement returns aResultSetobject, the given constant is not one of those allowed, the method is called on aPreparedStatementorCallableStatementSQLFeatureNotSupportedException- if the JDBC driver does not support this method with a constant of Statement.RETURN_GENERATED_KEYSSQLTimeoutException- when the driver has determined that the timeout value that was specified by thesetQueryTimeoutmethod has been exceeded and has at least attempted to cancel the currently runningStatement
-
executeLargeUpdate
public long executeLargeUpdate(String sql, int[] columnIndexes) throws SQLException
Executes the given SQL statement and signals the driver that the auto-generated keys indicated in the given array should be made available for retrieval.- Parameters:
sql- an SQL Data Manipulation Language (DML) statement, such asINSERT,UPDATEorDELETE; or an SQL statement that returns nothing, such as a DDL statement.columnIndexes- an array of column indexes indicating the columns that should be returned from the inserted row- Returns:
- either (1) the row count for SQL Data Manipulation Language (DML) statements or (2) 0 for SQL statements that return nothing
- Throws:
SQLException- if a database access error occurs, this method is called on a closedStatement, the SQL statement returns aResultSetobject,the second argument supplied to this method is not anintarray whose elements are valid column indexes, the method is called on aPreparedStatementorCallableStatementSQLFeatureNotSupportedException- if the JDBC driver does not support this methodSQLTimeoutException- when the driver has determined that the timeout value that was specified by thesetQueryTimeoutmethod has been exceeded and has at least attempted to cancel the currently runningStatement
-
executeLargeUpdate
public long executeLargeUpdate(String sql, String[] columnNames) throws SQLException
Executes the given SQL statement and signals the driver that the auto-generated keys indicated in the given array should be made available for retrieval.- Parameters:
sql- an SQL Data Manipulation Language (DML) statement, such asINSERT,UPDATEorDELETE; or an SQL statement that returns nothing, such as a DDL statement.columnNames- an array of the names of the columns that should be returned from the inserted row- Returns:
- either the row count for
INSERT,UPDATE, orDELETEstatements, or 0 for SQL statements that return nothing - Throws:
SQLException- if a database access error occurs, this method is called on a closedStatement, the SQL statement returns aResultSetobject, the second argument supplied to this method is not aStringarray whose elements are valid column names, the method is called on aPreparedStatementorCallableStatementSQLFeatureNotSupportedException- if the JDBC driver does not support this methodSQLTimeoutException- when the driver has determined that the timeout value that was specified by thesetQueryTimeoutmethod has been exceeded and has at least attempted to cancel the currently runningStatement
-
-