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 StringManager
localStrings
-
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.long
executeLargeUpdate(String sql)
Executes the given SQL statement, which may be anINSERT
,UPDATE
, orDELETE
statement or an SQL statement that returns nothing, such as an SQL DDL statement.long
executeLargeUpdate(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 thisStatement
object should be made available for retrieval.long
executeLargeUpdate(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.long
executeLargeUpdate(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.ResultSet
executeQuery(String sql)
Executes the given SQL statement, which returns a singleResultSet
object.ResultSet
getGeneratedKeys()
Retrieves any auto-generated keys created as a result of executing thisStatement
object.long
getLargeMaxRows()
Retrieves the maximum number of rows that aResultSet
object produced by thisStatement
object can contain.long
getLargeUpdateCount()
Retrieves the current result as an update count; if the result is aResultSet
object or there are no more results, -1 is returned.ResultSet
getResultSet()
Retrieves the current result as aResultSet
object.boolean
isClosed()
Retrieves whether thisStatement
object has been closed.boolean
isPoolable()
Returns a value indicating whether theStatement
is poolable or not.boolean
isWrapperFor(Class<?> iface)
Returns true if this either implements the interface argument or is directly or indirectly a wrapper for an object that does.void
setLargeMaxRows(long max)
Sets the limit for the maximum number of rows that anyResultSet
object generated by thisStatement
object can contain to the given number.void
setPoolable(boolean poolable)
Requests that aStatement
be pooled or not pooled.<T> T
unwrap(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 SQLException
Retrieves whether thisStatement
object has been closed. AStatement
is closed if the method close has been called on it, or if it is automatically closed.- Returns:
- true if this
Statement
object 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 SQLException
Requests that aStatement
be 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, aStatement
is not poolable when created, and aPreparedStatement
andCallableStatement
are 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 SQLException
Returns a value indicating whether theStatement
is poolable or not.- Returns:
true
if theStatement
is poolable;false
otherwise- 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
unwrap
recursively on the wrapped object or a proxy for that result. If the receiver is not a wrapper and does not implement the interface, then anSQLException
is 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 callingisWrapperFor
on 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 tounwrap
so that callers can use this method to avoid expensiveunwrap
calls that may fail. If this method returns true then callingunwrap
with 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 thisStatement
object. If thisStatement
object did not generate any keys, an emptyResultSet
object is returned.- Returns:
- a
ResultSet
object containing the auto-generated key(s) generated by the execution of thisStatement
object - Throws:
SQLException
- if a database access error occurs or this method is called on a closedStatement
SQLFeatureNotSupportedException
- if the JDBC driver does not support this method- Since:
- 1.4
-
getResultSet
public ResultSet getResultSet() throws SQLException
Retrieves the current result as aResultSet
object. This method should be called only once per result.- Returns:
- the current result as a
ResultSet
object ornull
if 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 singleResultSet
object.- Parameters:
sql
- an SQL statement to be sent to the database, typically a static SQLSELECT
statement- Returns:
- a
ResultSet
object that contains the data produced by the given query; nevernull
- Throws:
SQLException
- if a database access error occurs, this method is called on a closedStatement
or the given SQL statement produces anything other than a singleResultSet
object
-
getLargeUpdateCount
public long getLargeUpdateCount() throws SQLException
Retrieves the current result as an update count; if the result is aResultSet
object or there are no more results, -1 is returned.- Returns:
- the current result as an update count; -1 if the current result
is a
ResultSet
object 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 SQLException
Sets the limit for the maximum number of rows that anyResultSet
object generated by thisStatement
object 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 closedStatement
or the conditionmax >= 0
is not satisfied
-
getLargeMaxRows
public long getLargeMaxRows() throws SQLException
Retrieves the maximum number of rows that aResultSet
object produced by thisStatement
object can contain.- Returns:
- the current maximum number of rows for a
ResultSet
object produced by thisStatement
object; 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 SQLException
Submits 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 closedStatement
or 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 thesetQueryTimeout
method 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
, orDELETE
statement or an SQL statement that returns nothing, such as an SQL DDL statement.- Parameters:
sql
- an SQL Data Manipulation Language (DML) statement, such asINSERT
,UPDATE
orDELETE
; 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 aResultSet
object, the method is called on aPreparedStatement
orCallableStatement
SQLTimeoutException
- when the driver has determined that the timeout value that was specified by thesetQueryTimeout
method 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 thisStatement
object should be made available for retrieval.- Parameters:
sql
- an SQL Data Manipulation Language (DML) statement, such asINSERT
,UPDATE
orDELETE
; 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_KEYS
Statement.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 aResultSet
object, the given constant is not one of those allowed, the method is called on aPreparedStatement
orCallableStatement
SQLFeatureNotSupportedException
- 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 thesetQueryTimeout
method 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
,UPDATE
orDELETE
; 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 aResultSet
object,the second argument supplied to this method is not anint
array whose elements are valid column indexes, the method is called on aPreparedStatement
orCallableStatement
SQLFeatureNotSupportedException
- if the JDBC driver does not support this methodSQLTimeoutException
- when the driver has determined that the timeout value that was specified by thesetQueryTimeout
method 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
,UPDATE
orDELETE
; 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
, orDELETE
statements, 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 aResultSet
object, the second argument supplied to this method is not aString
array whose elements are valid column names, the method is called on aPreparedStatement
orCallableStatement
SQLFeatureNotSupportedException
- if the JDBC driver does not support this methodSQLTimeoutException
- when the driver has determined that the timeout value that was specified by thesetQueryTimeout
method has been exceeded and has at least attempted to cancel the currently runningStatement
-
-