public class StatementWrapper extends Object
| Constructor and Description | 
|---|
StatementWrapper(Statement stmt,
                ConnectionWrapper cw)
Constructs a StatementWrapper. 
 | 
| Modifier and Type | Method and Description | 
|---|---|
void | 
addBatch(String sql)
Adds the given SQL command to the current list of commmands for this 
 Statement object. 
 | 
void | 
cancel()
Cancel can be used by one thread to cancel an Ifstatement that
 is being executed by another thread. 
 | 
void | 
clearBatch()
Empties this Statement object's current list of SQL commands. 
 | 
void | 
clearWarnings()
After this call, getWarnings returns null until a new warning is
 reported for this StatementWrapper. 
 | 
void | 
close()
In many cases, it is desirable to immediately release a
 Statements's database and JDBC resources instead of waiting for
 this to happen when it is automatically closed; the close
 method provides this immediate release. 
 | 
static void | 
closeResultSet(ResultSet rset)
Close the specified ResultSet as a best effort; no exceptions thrown. 
 | 
static void | 
closeStatement(Statement stmt)
Close the specified Statement as a best effort; no exceptions thrown. 
 | 
static void | 
closeStatement(StatementWrapper stmt)
Close the specified wrapped Statement as a best effort; 
 no exceptions thrown. 
 | 
void | 
dispose()
Dispose and close the StatementWrapper. 
 | 
boolean | 
execute(String sql)
Execute a SQL statement that may return multiple results. 
 | 
int[] | 
executeBatch()
Submits a batch of commands to the database for execution and if all 
 commands execute successfully, returns an array of update counts. 
 | 
ResultSet | 
executeQuery(String sql)
Execute a SQL statement that returns a single ResultSet. 
 | 
int | 
executeUpdate(String sql)
Execute a SQL INSERT, UPDATE or DELETE statement. 
 | 
protected ConnectionWrapper | 
getConnectionWrapper()
Gets the ConnectionWrapper used to construct this instance. 
 | 
int | 
getMaxFieldSize()
The maxFieldSize limit (in bytes) is the maximum amount of data
 returned for any column value; it only applies to BINARY,
 VARBINARY, LONGVARBINARY, CHAR, VARCHAR, and LONGVARCHAR
 columns. 
 | 
int | 
getMaxRows()
The maxRows limit is the maximum number of rows that a
 ResultSet can contain. 
 | 
boolean | 
getMoreResults()
Moves to an StatementWrapper's next result. 
 | 
int | 
getQueryTimeout()
The queryTimeout limit is the number of seconds the driver will
 wait for an StatementWrapper to execute. 
 | 
ResultSet | 
getResultSet()
Returns the current result as a ResultSet. 
 | 
int | 
getUpdateCount()
Returns the current result as an update count;
 if the result is a ResultSet or there are no more results, -1
 is returned. 
 | 
SQLWarning | 
getWarnings()
The first warning reported by calls on this StatementWrapper is
 returned. 
 | 
void | 
setCursorName(String name)
Defines the SQL cursor name that will be used by
 subsequent Statement execute methods. 
 | 
void | 
setEscapeProcessing(boolean enable)
If escape scanning is on (the default), the driver will do
 escape substitution before sending the SQL to the database. 
 | 
void | 
setMaxFieldSize(int max)
The maxFieldSize limit (in bytes) is set to limit the size of
 data that can be returned for any column value; it only applies
 to BINARY, VARBINARY, LONGVARBINARY, CHAR, VARCHAR, and
 LONGVARCHAR fields. 
 | 
void | 
setMaxRows(int max)
The maxRows limit is set to limit the number of rows that any
 ResultSet can contain. 
 | 
void | 
setQueryTimeout(int seconds)
The queryTimeout limit is the number of seconds the driver will
 wait for an StatementWrapper to execute. 
 | 
public StatementWrapper(Statement stmt, ConnectionWrapper cw)
stmt - Statement instance to wrapcw - the ConnectionWrapper contextprotected ConnectionWrapper getConnectionWrapper()
public ResultSet executeQuery(String sql) throws SQLException
sql - typically this is a static SQL SELECT statementSQLException - if a database-access error occurs.public int executeUpdate(String sql) throws SQLException
sql - a SQL INSERT, UPDATE or DELETE statement or a SQL
                      statement that returns nothingSQLException - if a database-access error occurs.public boolean execute(String sql) throws SQLException
sql - the SQL stringSQLException - if a database-access error occurs.Statement.execute(java.lang.String)public int[] executeBatch()
                   throws SQLException
SQLException - if a database-access error occurs.public void close()
           throws SQLException
Note: A Statement is automatically closed when it is garbage collected. When a Statement is closed, its current ResultSet, if one exists, is also closed.
SQLException - if a database-access error occurs.public int getMaxFieldSize()
                    throws SQLException
SQLException - if a database-access error occurs.public void setMaxFieldSize(int max)
                     throws SQLException
max - the new max column size limit; zero means unlimitedSQLException - if a database-access error occurs.public int getMaxRows()
               throws SQLException
SQLException - if a database-access error occurs.public void setMaxRows(int max)
                throws SQLException
max - the new max rows limit; zero means unlimitedSQLException - if a database-access error occurs.public void setEscapeProcessing(boolean enable)
                         throws SQLException
enable - true to enable; false to disableSQLException - if a database-access error occurs.public int getQueryTimeout()
                    throws SQLException
SQLException - if a database-access error occurs.public void setQueryTimeout(int seconds)
                     throws SQLException
seconds - the new query timeout limit in seconds;
                      zero means unlimitedSQLException - if a database-access error occurs.public void cancel()
            throws SQLException
SQLException - if a database-access error occurs.public SQLWarning getWarnings() throws SQLException
The warning chain is automatically cleared each time a statement is (re)executed.
Note: If you are processing a ResultSet then any warnings associated with ResultSet reads will be chained on the ResultSet object.
SQLException - if a database-access error occurs.public void clearWarnings()
                   throws SQLException
SQLException - if a database-access error occurs.public void setCursorName(String name) throws SQLException
Note: By definition, positioned update/delete execution must be done by a different Statement than the one which generated the ResultSet being used for positioning. Also, cursor names must be unique within a Connection.
name - the new cursor name.SQLException - if a database-access error occurs.public ResultSet getResultSet() throws SQLException
SQLException - if a database-access error occurs.public int getUpdateCount()
                   throws SQLException
SQLException - if a database-access error occurs.public boolean getMoreResults()
                       throws SQLException
SQLException - if a database-access error occurs.public void addBatch(String sql) throws SQLException
sql - SQL stringSQLException - if a database-access error occurs.public void clearBatch()
                throws SQLException
SQLException - if a database-access error occurs.public void dispose()
public static void closeStatement(Statement stmt)
stmt - the Statement to closepublic static void closeStatement(StatementWrapper stmt)
stmt - the wrapped Statement to closepublic static void closeResultSet(ResultSet rset)
rset - the ResultSet to closeCopyright © 2025. All rights reserved.