public class ClientPreparedStatement extends BasePreparedStatement
batchParameters, canCachePrepStmts, parameters, prepareResult, sqlautoGeneratedKeys, closed, closeOnCompletion, con, currResult, escape, fetchSize, isInsertDuplicate, lastSql, localInfileInputStream, lock, maxRows, queryTimeout, results, resultSetConcurrency, resultSetTypeCLOSE_ALL_RESULTS, CLOSE_CURRENT_RESULT, EXECUTE_FAILED, KEEP_CURRENT_RESULT, NO_GENERATED_KEYS, RETURN_GENERATED_KEYS, SUCCESS_NO_INFO| Constructor and Description |
|---|
ClientPreparedStatement(String sql,
Connection con,
ClosableLock lock,
int autoGeneratedKeys,
int resultSetType,
int resultSetConcurrency,
int defaultFetchSize)
Client prepare statement constructor
|
| Modifier and Type | Method and Description |
|---|---|
void |
addBatch()
Adds a set of parameters to this
PreparedStatement object's batch of commands. |
void |
clearBatch()
Empties this
PreparedStatement object's current list of parameters. |
void |
close()
Releases this
Statement object's database and JDBC resources immediately instead
of waiting for this to happen when it is automatically closed. |
boolean |
execute()
Executes the SQL statement in this
PreparedStatement object, which may be any kind
of SQL statement. |
int[] |
executeBatch()
Submits a batch of commands to the database for execution and if all commands execute
successfully, returns an array of update counts.
|
long[] |
executeLargeBatch()
Execute batch, like executeBatch(), with returning results with long[].
|
long |
executeLargeUpdate()
Executes the SQL statement in this
PreparedStatement object, which must be an SQL
Data Manipulation Language (DML) statement, such as INSERT, UPDATE or
DELETE; or an SQL statement that returns nothing, such as a DDL statement. |
ResultSet |
executeQuery()
Executes the SQL query in this
PreparedStatement object and returns the
ResultSet object generated by the query. |
int |
executeUpdate()
Executes the SQL statement in this
PreparedStatement object, which must be an SQL
Data Manipulation Language (DML) statement, such as INSERT, UPDATE or
DELETE; or an SQL statement that returns nothing, such as a DDL statement. |
ResultSetMetaData |
getMetaData()
Retrieves a
ResultSetMetaData object that contains information about the columns
of the ResultSet object that will be returned when this PreparedStatement
object is executed. |
ParameterMetaData |
getParameterMetaData()
Retrieves the number, types and properties of this
PreparedStatement object's
parameters. |
void |
setLargeMaxRows(long max)
Sets the limit for the maximum number of rows that any ResultSet object generated by this
Statement object can contain to the given number.
|
void |
setMaxRows(int max)
Sets the limit for the maximum number of rows that any
ResultSet object generated
by this Statement object can contain to the given number. |
void |
setQueryTimeout(int seconds)
Sets the number of seconds the driver will wait for a
Statement object to execute
to the given number of seconds. |
String |
toString() |
protected void |
validParameters() |
addBatch, clearParameters, execute, execute, execute, execute, executeLargeUpdate, executeLargeUpdate, executeLargeUpdate, executeLargeUpdate, executeQuery, executeUpdate, executeUpdate, executeUpdate, executeUpdate, getLastSql, getMeta, reset, setArray, setAsciiStream, setAsciiStream, setAsciiStream, setBigDecimal, setBinaryStream, setBinaryStream, setBinaryStream, setBlob, setBlob, setBlob, setBoolean, setByte, setBytes, setCharacterStream, setCharacterStream, setCharacterStream, setClob, setClob, setClob, setDate, setDate, setDouble, setFloat, setInt, setLong, setNCharacterStream, setNCharacterStream, setNClob, setNClob, setNClob, setNString, setNull, setNull, setObject, setObject, setObject, setObject, setObject, setParameter, setParameters, setPrepareResult, setRef, setRowId, setShort, setSQLXML, setString, setTime, setTime, setTimestamp, setTimestamp, setUnicodeStream, setURL, updateMetaabort, cancel, checkNotClosed, clearWarnings, closeOnCompletion, enquoteIdentifier, enquoteLiteral, enquoteNCharLiteral, escapeTimeout, fetchRemaining, getConnection, getFetchDirection, getFetchSize, getGeneratedKeys, getLargeMaxRows, getLargeUpdateCount, getMaxFieldSize, getMaxRows, getMoreResults, getMoreResults, getNextLocalInfileInputStream, getQueryTimeout, getResultSet, getResultSetConcurrency, getResultSetHoldability, getResultSetType, getUpdateCount, getWarnings, isClosed, isCloseOnCompletion, isPoolable, isWrapperFor, setCursorName, setEscapeProcessing, setFetchDirection, setFetchSize, setLocalInfileInputStream, setMaxFieldSize, setNextLocalInfileInputStream, setPoolable, unwrapclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitcancel, clearWarnings, closeOnCompletion, getConnection, getFetchDirection, getFetchSize, getGeneratedKeys, getLargeMaxRows, getLargeUpdateCount, getMaxFieldSize, getMaxRows, getMoreResults, getMoreResults, getQueryTimeout, getResultSet, getResultSetConcurrency, getResultSetHoldability, getResultSetType, getUpdateCount, getWarnings, isClosed, isCloseOnCompletion, isPoolable, setCursorName, setEscapeProcessing, setFetchDirection, setFetchSize, setMaxFieldSize, setPoolableisWrapperFor, unwrappublic ClientPreparedStatement(String sql, Connection con, ClosableLock lock, int autoGeneratedKeys, int resultSetType, int resultSetConcurrency, int defaultFetchSize)
sql - commandcon - connectionlock - thread safe lockautoGeneratedKeys - must command return automatically generated keysresultSetType - resultset typeresultSetConcurrency - resultset concurrencydefaultFetchSize - default fetch sizepublic boolean execute()
throws SQLException
PreparedStatement object, which may be any kind
of SQL statement. Some prepared statements return multiple results; the execute
method handles these complex statements as well as the simpler form of statements handled by
the methods executeQuery and executeUpdate.
The execute method returns a boolean to indicate the form of the
first result. You must call either the method getResultSet or getUpdateCount
to retrieve the result; you must call getMoreResults to move to any
subsequent result(s).
execute in interface PreparedStatementexecute in class BasePreparedStatementtrue if the first result is a ResultSet object; false
if the first result is an update count or there is no resultSQLException - if a database access error occurs; this method is called on a closed
PreparedStatement or an argument is supplied to this methodSQLTimeoutException - when the driver has determined that the timeout value that was
specified by the setQueryTimeout method has been exceeded and has at least
attempted to cancel the currently running StatementStatement.execute(java.lang.String),
Statement.getResultSet(),
Statement.getUpdateCount(),
Statement.getMoreResults()public ResultSet executeQuery() throws SQLException
PreparedStatement object and returns the
ResultSet object generated by the query.executeQuery in interface PreparedStatementexecuteQuery in class BasePreparedStatementResultSet object that contains the data produced by the query; never
nullSQLException - if a database access error occurs; this method is called on a closed
PreparedStatement or the SQL statement does not return a ResultSet
objectSQLTimeoutException - when the driver has determined that the timeout value that was
specified by the setQueryTimeout method has been exceeded and has at least
attempted to cancel the currently running Statementpublic int executeUpdate()
throws SQLException
PreparedStatement object, which must be an SQL
Data Manipulation Language (DML) statement, such as INSERT, UPDATE or
DELETE; or an SQL statement that returns nothing, such as a DDL statement.executeUpdate in interface PreparedStatementexecuteUpdate in class BasePreparedStatementSQLException - if a database access error occurs; this method is called on a closed
PreparedStatement or the SQL statement returns a ResultSet objectSQLTimeoutException - when the driver has determined that the timeout value that was
specified by the setQueryTimeout method has been exceeded and has at least
attempted to cancel the currently running Statementpublic long executeLargeUpdate()
throws SQLException
PreparedStatement object, which must be an SQL
Data Manipulation Language (DML) statement, such as INSERT, UPDATE or
DELETE; or an SQL statement that returns nothing, such as a DDL statement.
This method should be used when the returned row count may exceed Integer.MAX_VALUE.
The default implementation will throw UnsupportedOperationException
executeLargeUpdate in interface PreparedStatementexecuteLargeUpdate in class BasePreparedStatementSQLException - if a database access error occurs; this method is called on a closed
PreparedStatement or the SQL statement returns a ResultSet objectSQLTimeoutException - when the driver has determined that the timeout value that was
specified by the setQueryTimeout method has been exceeded and has at least
attempted to cancel the currently running Statementpublic void addBatch()
throws SQLException
PreparedStatement object's batch of commands.addBatch in interface PreparedStatementaddBatch in class BasePreparedStatementSQLException - if a database access error occurs or this method is called on a closed
PreparedStatementStatement.addBatch(java.lang.String)public void clearBatch()
throws SQLException
PreparedStatement object's current list of parameters.clearBatch in interface StatementclearBatch in class BasePreparedStatementSQLException - if a database access error occurs, this method is called on a closed
Statement or the driver does not support batch updatesaddBatch(),
DatabaseMetaData.supportsBatchUpdates()protected void validParameters()
throws SQLException
SQLExceptionpublic void setQueryTimeout(int seconds)
throws SQLException
StatementStatement object to execute
to the given number of seconds. By default there is no limit on the amount of time allowed for
a running statement to complete. If the limit is exceeded, an SQLTimeoutException
is thrown. A JDBC driver must apply this limit to the execute, executeQuery
and executeUpdate methods.
Note: JDBC driver implementations may also apply this limit to ResultSet methods (consult your driver vendor documentation for details).
Note: In the case of Statement batching, it is implementation
defined as to whether the time-out is applied to individual SQL commands added via the addBatch method or to the entire batch of SQL commands invoked by the executeBatch
method (consult your driver vendor documentation for details).
setQueryTimeout in interface StatementsetQueryTimeout in class Statementseconds - the new query timeout limit in seconds; zero means there is no limitSQLException - if a database access error occurs, this method is called on a closed
Statement or the condition seconds >= 0 is not satisfiedStatement.getQueryTimeout()public void setMaxRows(int max)
throws SQLException
StatementResultSet object generated
by this Statement object can contain to the given number. If the limit is
exceeded, the excess rows are silently dropped.setMaxRows in interface StatementsetMaxRows in class Statementmax - the new max rows limit; zero means there is no limitSQLException - if a database access error occurs, this method is called on a closed
Statement or the condition max >= 0 is not satisfiedStatement.getMaxRows()public void setLargeMaxRows(long max)
throws SQLException
StatementConnection.setSqlSelectLimit(long).setLargeMaxRows in interface StatementsetLargeMaxRows in class Statementmax - the new max rows limit; zero means there is no limitSQLException - if the condition max >= 0 is not satisfiedpublic ResultSetMetaData getMetaData() throws SQLException
ResultSetMetaData object that contains information about the columns
of the ResultSet object that will be returned when this PreparedStatement
object is executed.
Because a PreparedStatement object is precompiled, it is possible to know about
the ResultSet object that it will return without having to execute it.
Consequently, it is possible to invoke the method getMetaData on a
PreparedStatement object rather than waiting to execute it and then invoking the
ResultSet.getMetaData method on the ResultSet object that is returned.
NOTE: Using this method may be expensive for some drivers due to the lack of underlying DBMS support.
getMetaData in interface PreparedStatementgetMetaData in class BasePreparedStatementResultSet object's columns or null if
the driver cannot return a ResultSetMetaData objectSQLException - if a database access error occurs or this method is called on a closed
PreparedStatementSQLFeatureNotSupportedException - if the JDBC driver does not support this methodpublic ParameterMetaData getParameterMetaData() throws SQLException
PreparedStatement object's
parameters.getParameterMetaData in interface PreparedStatementgetParameterMetaData in class BasePreparedStatementParameterMetaData object that contains information about the number,
types and properties for each parameter marker of this PreparedStatement
objectSQLException - if a database access error occurs or this method is called on a closed
PreparedStatementParameterMetaDatapublic int[] executeBatch()
throws SQLException
Statementint elements of the array
that is returned are ordered to correspond to the commands in the batch, which are ordered
according to the order in which they were added to the batch. The elements in the array
returned by the method executeBatch may be one of the following:
SUCCESS_NO_INFO -- indicates that the command was processed
successfully but that the number of rows affected is unknown
If one of the commands in a batch update fails to execute properly, this method throws
a BatchUpdateException, and a JDBC driver may or may not continue to process
the remaining commands in the batch. However, the driver's behavior must be consistent
with a particular DBMS, either always continuing to process commands or never continuing
to process commands. If the driver continues processing after a failure, the array
returned by the method BatchUpdateException.getUpdateCounts will contain as
many elements as there are commands in the batch, and at least one of the elements will
be the following:
EXECUTE_FAILED -- indicates that the command failed to execute
successfully and occurs only if a driver continues to process commands after a command
fails
The possible implementations and return values have been modified in the Java 2 SDK,
Standard Edition, version 1.3 to accommodate the option of continuing to process commands in a
batch update after a BatchUpdateException object has been thrown.
executeBatch in interface StatementexecuteBatch in class BasePreparedStatementSQLException - if a database access error occurs, this method is called on a closed
Statement or the driver does not support batch statements. Throws BatchUpdateException (a subclass of SQLException) 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 the setQueryTimeout method has been exceeded and has at least
attempted to cancel the currently running StatementStatement.addBatch(java.lang.String),
DatabaseMetaData.supportsBatchUpdates()public long[] executeLargeBatch()
throws SQLException
StatementexecuteLargeBatch in interface StatementexecuteLargeBatch in class BasePreparedStatementSQLException - if a database error occur.public void close()
throws SQLException
StatementStatement object's database and JDBC resources immediately instead
of waiting for this to happen when it is automatically closed. It is generally good practice to
release resources as soon as you are finished with them to avoid tying up database resources.
Calling the method close on a Statement object that is already
closed has no effect.
Note:When a Statement object is closed, its current ResultSet
object, if one exists, is also closed.
close in interface AutoCloseableclose in interface Statementclose in class StatementSQLException - if a database access error occurspublic String toString()
toString in class BasePreparedStatementCopyright © 2025 SingleStore. All rights reserved.