Package com.mysql.cj.jdbc
Class ClientPreparedStatement
java.lang.Object
com.mysql.cj.jdbc.StatementImpl
com.mysql.cj.jdbc.ClientPreparedStatement
- All Implemented Interfaces:
JdbcPreparedStatement
,JdbcStatement
,Query
,java.lang.AutoCloseable
,java.sql.PreparedStatement
,java.sql.Statement
,java.sql.Wrapper
- Direct Known Subclasses:
CallableStatement
,ServerPreparedStatement
public class ClientPreparedStatement extends StatementImpl implements JdbcPreparedStatement
A SQL Statement is pre-compiled and stored in a PreparedStatement object. This object can then be used to efficiently execute this statement multiple times.
Note: The setXXX methods for setting IN parameter values must specify types that are compatible with the defined SQL type of the input parameter. For instance, if the IN parameter has SQL type Integer, then setInt should be used.
If arbitrary parameter type conversions are required, then the setObject method should be used with a target SQL type.
-
Nested Class Summary
-
Field Summary
Fields Modifier and Type Field Description protected java.lang.String
batchedValuesClause
protected boolean
batchHasPlainStatements
Does the batch (if any) contain "plain" statements added by Statement.addBatch(String)? If so, we can't re-write it to use multi-value or multi-queries.protected MysqlParameterMetadata
parameterMetaData
protected int
rewrittenBatchSize
Fields inherited from class com.mysql.cj.jdbc.StatementImpl
batchedGeneratedKeys, charEncoding, commandBuilder, connection, continueBatchOnError, doEscapeProcessing, dontCheckOnDuplicateKeyUpdateInSQL, dontTrackOpenResources, dumpQueriesOnException, exceptionInterceptor, generatedKeysResults, holdResultsOpenOverClose, isClosed, lastInsertId, lastQueryIsOnDupKeyUpdate, logSlowQueries, maxAllowedPacket, maxFieldSize, maxRows, openResults, pedantic, PING_MARKER, pingTarget, profileSQL, query, results, resultSetConcurrency, resultSetFactory, retrieveGeneratedKeys, rewriteBatchedStatements, session, updateCount, USES_VARIABLES_FALSE, USES_VARIABLES_TRUE, USES_VARIABLES_UNKNOWN, useUsageAdvisor, warningChain
-
Constructor Summary
Constructors Modifier Constructor Description protected
ClientPreparedStatement(JdbcConnection conn, java.lang.String db)
Constructor used by server-side prepared statementsClientPreparedStatement(JdbcConnection conn, java.lang.String sql, java.lang.String db)
Constructor for the PreparedStatement class.ClientPreparedStatement(JdbcConnection conn, java.lang.String sql, java.lang.String db, ParseInfo cachedParseInfo)
Creates a new PreparedStatement object. -
Method Summary
Modifier and Type Method Description void
addBatch()
void
addBatch(java.lang.String sql)
java.lang.String
asSql()
java.lang.String
asSql(boolean quoteStreamsAndUnknowns)
protected void
checkBounds(int paramIndex, int parameterIndexOffset)
protected boolean
checkReadOnlySafeStatement()
Check to see if the statement is safe for read-only replicas after failover.void
clearBatch()
void
clearParameters()
protected boolean
containsOnDuplicateKeyUpdateInSQL()
boolean
execute()
protected long[]
executeBatchedInserts(int batchTimeout)
Rewrites the already prepared statement into a multi-value insert statement of 'statementsPerBatch' values and executes the entire batch using this new statement.protected long[]
executeBatchInternal()
protected long[]
executeBatchSerially(int batchTimeout)
Executes the current batch of statements by executing them one-by-one.protected <M extends Message>
ResultSetInternalMethodsexecuteInternal(int maxRowsToRetrieve, M sendPacket, boolean createStreamingResultSet, boolean queryIsSelectOnly, ColumnDefinition metadata, boolean isBatch)
Actually execute the prepared statement.long
executeLargeUpdate()
protected long[]
executePreparedBatchAsMultiStatement(int batchTimeout)
Rewrites the already prepared statement into a multi-statement query of 'statementsPerBatch' values and executes the entire batch using this new statement.java.sql.ResultSet
executeQuery()
int
executeUpdate()
protected long
executeUpdateInternal(boolean clearBatchedGeneratedKeysAndWarnings, boolean isBatch)
protected long
executeUpdateInternal(QueryBindings<?> bindings, boolean isReallyBatch)
Added to allow batch-updatesbyte[]
getBytesRepresentation(int parameterIndex)
int
getCoreParameterIndex(int paramIndex)
protected static ClientPreparedStatement
getInstance(JdbcConnection conn, java.lang.String sql, java.lang.String db)
Creates a prepared statement instanceprotected static ClientPreparedStatement
getInstance(JdbcConnection conn, java.lang.String sql, java.lang.String db, ParseInfo cachedParseInfo)
Creates a prepared statement instancejava.sql.ResultSetMetaData
getMetaData()
byte[]
getOrigBytes(int parameterIndex)
ParameterBindings
getParameterBindings()
protected int
getParameterIndexOffset()
For calling stored functions, this will be -1 as Connector/J does not count the first '?' parameter marker, but JDBC counts it * as 1, otherwise it will return 0java.sql.ParameterMetaData
getParameterMetaData()
ParseInfo
getParseInfo()
java.lang.String
getPreparedSql()
QueryBindings<?>
getQueryBindings()
int
getUpdateCount()
protected void
initQuery()
boolean
isNull(int paramIndex)
protected boolean
isSelectQuery()
protected ClientPreparedStatement
prepareBatchedInsertSQL(JdbcConnection localConn, int numBatches)
Returns a prepared statement for the number of batched parameters, used when re-writing batch INSERTs.void
realClose(boolean calledExplicitly, boolean closeOpenResults)
Closes this statement, and frees resources.void
setArray(int i, java.sql.Array x)
void
setAsciiStream(int parameterIndex, java.io.InputStream x)
void
setAsciiStream(int parameterIndex, java.io.InputStream x, int length)
void
setAsciiStream(int parameterIndex, java.io.InputStream x, long length)
void
setBigDecimal(int parameterIndex, java.math.BigDecimal x)
void
setBigInteger(int parameterIndex, java.math.BigInteger x)
void
setBinaryStream(int parameterIndex, java.io.InputStream x)
void
setBinaryStream(int parameterIndex, java.io.InputStream x, int length)
void
setBinaryStream(int parameterIndex, java.io.InputStream x, long length)
void
setBlob(int parameterIndex, java.io.InputStream inputStream)
void
setBlob(int parameterIndex, java.io.InputStream inputStream, long length)
void
setBlob(int i, java.sql.Blob x)
void
setBoolean(int parameterIndex, boolean x)
void
setByte(int parameterIndex, byte x)
void
setBytes(int parameterIndex, byte[] x)
void
setBytes(int parameterIndex, byte[] x, boolean checkForIntroducer, boolean escapeForMBChars)
void
setBytesNoEscape(int parameterIndex, byte[] parameterAsBytes)
Used by updatable result sets for refreshRow() because the parameter has already been escaped for updater or inserter prepared statements.void
setBytesNoEscapeNoQuotes(int parameterIndex, byte[] parameterAsBytes)
void
setCharacterStream(int parameterIndex, java.io.Reader reader)
void
setCharacterStream(int parameterIndex, java.io.Reader reader, int length)
void
setCharacterStream(int parameterIndex, java.io.Reader reader, long length)
void
setClob(int parameterIndex, java.io.Reader reader)
void
setClob(int parameterIndex, java.io.Reader reader, long length)
void
setClob(int i, java.sql.Clob x)
void
setDate(int parameterIndex, java.sql.Date x)
void
setDate(int parameterIndex, java.sql.Date x, java.util.Calendar cal)
void
setDouble(int parameterIndex, double x)
void
setFloat(int parameterIndex, float x)
void
setInt(int parameterIndex, int x)
void
setLong(int parameterIndex, long x)
void
setNCharacterStream(int parameterIndex, java.io.Reader value)
void
setNCharacterStream(int parameterIndex, java.io.Reader reader, long length)
void
setNClob(int parameterIndex, java.io.Reader reader)
void
setNClob(int parameterIndex, java.io.Reader reader, long length)
void
setNClob(int parameterIndex, java.sql.NClob value)
void
setNString(int parameterIndex, java.lang.String x)
Set a parameter to a Java String value.void
setNull(int parameterIndex, int sqlType)
void
setNull(int parameterIndex, int sqlType, java.lang.String typeName)
void
setNull(int parameterIndex, MysqlType mysqlType)
void
setObject(int parameterIndex, java.lang.Object parameterObj)
void
setObject(int parameterIndex, java.lang.Object parameterObj, int targetSqlType)
void
setObject(int parameterIndex, java.lang.Object parameterObj, int targetSqlType, int scale)
void
setObject(int parameterIndex, java.lang.Object parameterObj, java.sql.SQLType targetSqlType)
void
setObject(int parameterIndex, java.lang.Object x, java.sql.SQLType targetSqlType, int scaleOrLength)
protected int
setOneBatchedParameterSet(java.sql.PreparedStatement batchedStatement, int batchedParamIndex, java.lang.Object paramSet)
void
setRef(int i, java.sql.Ref x)
protected void
setRetrieveGeneratedKeys(boolean flag)
void
setRowId(int parameterIndex, java.sql.RowId x)
void
setShort(int parameterIndex, short x)
void
setSQLXML(int parameterIndex, java.sql.SQLXML xmlObject)
void
setString(int parameterIndex, java.lang.String x)
void
setTime(int parameterIndex, java.sql.Time x)
void
setTime(int parameterIndex, java.sql.Time x, java.util.Calendar cal)
void
setTimestamp(int parameterIndex, java.sql.Timestamp x)
void
setTimestamp(int parameterIndex, java.sql.Timestamp x, java.util.Calendar cal)
void
setTimestamp(int parameterIndex, java.sql.Timestamp x, java.util.Calendar targetCalendar, int fractionalLength)
void
setUnicodeStream(int parameterIndex, java.io.InputStream x, int length)
Deprecated.void
setURL(int parameterIndex, java.net.URL arg)
java.lang.String
toString()
Returns this PreparedStatement represented as a string.Methods inherited from class com.mysql.cj.jdbc.StatementImpl
addBatch, cancel, checkCancelTimeout, checkClosed, checkForDml, checkNullOrEmptyQuery, clearBatchedArgs, clearWarnings, close, closeAllOpenResults, closeOnCompletion, closeQuery, containsOnDuplicateKeyInString, createStreamingResultSet, disableStreamingResults, doPingInstead, enableStreamingResults, execute, execute, execute, execute, executeBatch, executeLargeBatch, executeLargeUpdate, executeLargeUpdate, executeLargeUpdate, executeLargeUpdate, executeQuery, executeSimpleNonQuery, executeUpdate, executeUpdate, executeUpdate, executeUpdate, executeUpdateInternal, findStartOfStatement, generatePingResultSet, getBatchedArgs, getBatchedGeneratedKeys, getBatchedGeneratedKeys, getCancelTimeoutMutex, getConnection, getCurrentDatabase, getExceptionInterceptor, getExecuteTime, getFetchDirection, getFetchSize, getGeneratedKeys, getGeneratedKeysInternal, getGeneratedKeysInternal, getId, getLargeMaxRows, getLargeUpdateCount, getLastInsertID, getLocalInfileInputStream, getLongUpdateCount, getMaxFieldSize, getMaxRows, getMoreResults, getMoreResults, getOpenResultSetCount, getQuery, getQueryTimeout, getResultFetchSize, getResultSet, getResultSetConcurrency, getResultSetFactory, getResultSetHoldability, getResultSetInternal, getResultSetType, getResultType, getServerStatementId, getSession, getStatementExecuting, getTimeoutInMillis, getWarnings, handleExceptionForBatch, hasDeadlockOrTimeoutRolledBackTx, implicitlyCloseAllOpenResults, isClearWarningsCalled, isClosed, isCloseOnCompletion, isPoolable, isWrapperFor, processMultiCountsAndKeys, removeOpenResultSet, resetCancelledState, setCancelStatus, setClearWarningsCalled, setCurrentDatabase, setCursorName, setEscapeProcessing, setExecuteTime, setFetchDirection, setFetchSize, setHoldResultsOpenOverClose, setLargeMaxRows, setLocalInfileInputStream, setMaxFieldSize, setMaxRows, setPingTarget, setPoolable, setQueryTimeout, setResultFetchSize, setResultType, setTimeoutInMillis, setupStreamingTimeout, startQueryTimer, statementBegins, stopQueryTimer, unwrap
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface com.mysql.cj.jdbc.JdbcStatement
disableStreamingResults, enableStreamingResults, getExceptionInterceptor, getLocalInfileInputStream, getOpenResultSetCount, getQuery, removeOpenResultSet, setHoldResultsOpenOverClose, setLocalInfileInputStream, setPingTarget
Methods inherited from interface com.mysql.cj.Query
addBatch, checkCancelTimeout, clearBatchedArgs, closeQuery, getBatchedArgs, getCancelTimeoutMutex, getCurrentDatabase, getExecuteTime, getId, getResultFetchSize, getResultSetFactory, getResultType, getSession, getStatementExecuting, getTimeoutInMillis, isClearWarningsCalled, resetCancelledState, setCancelStatus, setClearWarningsCalled, setCurrentDatabase, setExecuteTime, setResultFetchSize, setResultType, setTimeoutInMillis, startQueryTimer, statementBegins, stopQueryTimer
Methods inherited from interface java.sql.Statement
cancel, clearWarnings, close, closeOnCompletion, enquoteIdentifier, enquoteLiteral, enquoteNCharLiteral, execute, execute, execute, execute, executeBatch, executeLargeBatch, executeLargeUpdate, executeLargeUpdate, executeLargeUpdate, executeLargeUpdate, executeQuery, executeUpdate, executeUpdate, executeUpdate, executeUpdate, getConnection, getFetchDirection, getFetchSize, getGeneratedKeys, getLargeMaxRows, getLargeUpdateCount, getMaxFieldSize, getMaxRows, getMoreResults, getMoreResults, getQueryTimeout, getResultSet, getResultSetConcurrency, getResultSetHoldability, getResultSetType, getWarnings, isClosed, isCloseOnCompletion, isPoolable, isSimpleIdentifier, setCursorName, setEscapeProcessing, setFetchDirection, setFetchSize, setLargeMaxRows, setMaxFieldSize, setMaxRows, setPoolable, setQueryTimeout
-
Field Details
-
batchHasPlainStatements
protected boolean batchHasPlainStatementsDoes the batch (if any) contain "plain" statements added by Statement.addBatch(String)? If so, we can't re-write it to use multi-value or multi-queries. -
parameterMetaData
-
batchedValuesClause
protected java.lang.String batchedValuesClause -
rewrittenBatchSize
protected int rewrittenBatchSize
-
-
Constructor Details
-
ClientPreparedStatement
protected ClientPreparedStatement(JdbcConnection conn, java.lang.String db) throws java.sql.SQLExceptionConstructor used by server-side prepared statements- Parameters:
conn
- the connection that created usdb
- the database in use when we were created- Throws:
java.sql.SQLException
- if an error occurs
-
ClientPreparedStatement
public ClientPreparedStatement(JdbcConnection conn, java.lang.String sql, java.lang.String db) throws java.sql.SQLExceptionConstructor for the PreparedStatement class.- Parameters:
conn
- the connection creating this statementsql
- the SQL for this statementdb
- the database this statement should be issued against- Throws:
java.sql.SQLException
- if a database error occurs.
-
ClientPreparedStatement
public ClientPreparedStatement(JdbcConnection conn, java.lang.String sql, java.lang.String db, ParseInfo cachedParseInfo) throws java.sql.SQLExceptionCreates a new PreparedStatement object.- Parameters:
conn
- the connection creating this statementsql
- the SQL for this statementdb
- the database this statement should be issued againstcachedParseInfo
- already created parseInfo or null.- Throws:
java.sql.SQLException
- if a database access error occurs
-
-
Method Details
-
getInstance
protected static ClientPreparedStatement getInstance(JdbcConnection conn, java.lang.String sql, java.lang.String db) throws java.sql.SQLExceptionCreates a prepared statement instance- Parameters:
conn
- the connection creating this statementsql
- the SQL for this statementdb
- the database this statement should be issued against- Returns:
- ClientPreparedStatement
- Throws:
java.sql.SQLException
- if a database access error occurs
-
getInstance
protected static ClientPreparedStatement getInstance(JdbcConnection conn, java.lang.String sql, java.lang.String db, ParseInfo cachedParseInfo) throws java.sql.SQLExceptionCreates a prepared statement instance- Parameters:
conn
- the connection creating this statementsql
- the SQL for this statementdb
- the database this statement should be issued againstcachedParseInfo
- already created parseInfo or null.- Returns:
- ClientPreparedStatement instance
- Throws:
java.sql.SQLException
- if a database access error occurs
-
initQuery
protected void initQuery()- Overrides:
initQuery
in classStatementImpl
-
getQueryBindings
- Specified by:
getQueryBindings
in interfaceJdbcPreparedStatement
-
toString
public java.lang.String toString()Returns this PreparedStatement represented as a string.- Overrides:
toString
in classjava.lang.Object
- Returns:
- this PreparedStatement represented as a string.
-
addBatch
public void addBatch() throws java.sql.SQLException- Specified by:
addBatch
in interfacejava.sql.PreparedStatement
- Throws:
java.sql.SQLException
-
addBatch
public void addBatch(java.lang.String sql) throws java.sql.SQLException- Specified by:
addBatch
in interfacejava.sql.Statement
- Overrides:
addBatch
in classStatementImpl
- Throws:
java.sql.SQLException
-
asSql
public java.lang.String asSql() throws java.sql.SQLException- Throws:
java.sql.SQLException
-
asSql
public java.lang.String asSql(boolean quoteStreamsAndUnknowns) throws java.sql.SQLException- Throws:
java.sql.SQLException
-
clearBatch
public void clearBatch() throws java.sql.SQLException- Specified by:
clearBatch
in interfacejava.sql.Statement
- Overrides:
clearBatch
in classStatementImpl
- Throws:
java.sql.SQLException
-
clearParameters
public void clearParameters() throws java.sql.SQLException- Specified by:
clearParameters
in interfacejava.sql.PreparedStatement
- Throws:
java.sql.SQLException
-
checkReadOnlySafeStatement
protected boolean checkReadOnlySafeStatement() throws java.sql.SQLExceptionCheck to see if the statement is safe for read-only replicas after failover.- Returns:
- true if safe for read-only.
- Throws:
java.sql.SQLException
- if a database access error occurs or this method is called on a closed PreparedStatement
-
execute
public boolean execute() throws java.sql.SQLException- Specified by:
execute
in interfacejava.sql.PreparedStatement
- Throws:
java.sql.SQLException
-
executeBatchInternal
protected long[] executeBatchInternal() throws java.sql.SQLException- Overrides:
executeBatchInternal
in classStatementImpl
- Throws:
java.sql.SQLException
-
executePreparedBatchAsMultiStatement
protected long[] executePreparedBatchAsMultiStatement(int batchTimeout) throws java.sql.SQLExceptionRewrites the already prepared statement into a multi-statement query of 'statementsPerBatch' values and executes the entire batch using this new statement.- Parameters:
batchTimeout
- timeout for the batch execution- Returns:
- update counts in the same fashion as executeBatch()
- Throws:
java.sql.SQLException
- if a database access error occurs or this method is called on a closed PreparedStatement
-
setOneBatchedParameterSet
protected int setOneBatchedParameterSet(java.sql.PreparedStatement batchedStatement, int batchedParamIndex, java.lang.Object paramSet) throws java.sql.SQLException- Throws:
java.sql.SQLException
-
executeBatchedInserts
protected long[] executeBatchedInserts(int batchTimeout) throws java.sql.SQLExceptionRewrites the already prepared statement into a multi-value insert statement of 'statementsPerBatch' values and executes the entire batch using this new statement.- Parameters:
batchTimeout
- timeout for the batch execution- Returns:
- update counts in the same fashion as executeBatch()
- Throws:
java.sql.SQLException
- if a database access error occurs or this method is called on a closed PreparedStatement
-
executeBatchSerially
protected long[] executeBatchSerially(int batchTimeout) throws java.sql.SQLExceptionExecutes the current batch of statements by executing them one-by-one.- Parameters:
batchTimeout
- timeout for the batch execution- Returns:
- a list of update counts
- Throws:
java.sql.SQLException
- if an error occurs
-
executeInternal
protected <M extends Message> ResultSetInternalMethods executeInternal(int maxRowsToRetrieve, M sendPacket, boolean createStreamingResultSet, boolean queryIsSelectOnly, ColumnDefinition metadata, boolean isBatch) throws java.sql.SQLExceptionActually execute the prepared statement. This is here so server-side PreparedStatements can re-use most of the code from this class.- Type Parameters:
M
- extendsMessage
- Parameters:
maxRowsToRetrieve
- the max number of rows to returnsendPacket
- the packet to sendcreateStreamingResultSet
- should a 'streaming' result set be created?queryIsSelectOnly
- is this query doing a SELECT?metadata
- use this metadata instead of the one provided on wireisBatch
- is this a batch query?- Returns:
- the results as a ResultSet
- Throws:
java.sql.SQLException
- if an error occurs.
-
executeQuery
public java.sql.ResultSet executeQuery() throws java.sql.SQLException- Specified by:
executeQuery
in interfacejava.sql.PreparedStatement
- Throws:
java.sql.SQLException
-
executeUpdate
public int executeUpdate() throws java.sql.SQLException- Specified by:
executeUpdate
in interfacejava.sql.PreparedStatement
- Throws:
java.sql.SQLException
-
executeUpdateInternal
protected long executeUpdateInternal(boolean clearBatchedGeneratedKeysAndWarnings, boolean isBatch) throws java.sql.SQLException- Throws:
java.sql.SQLException
-
executeUpdateInternal
protected long executeUpdateInternal(QueryBindings<?> bindings, boolean isReallyBatch) throws java.sql.SQLExceptionAdded to allow batch-updates- Parameters:
bindings
- bindings objectisReallyBatch
- is it a batched statement?- Returns:
- the update count
- Throws:
java.sql.SQLException
- if a database error occurs
-
containsOnDuplicateKeyUpdateInSQL
protected boolean containsOnDuplicateKeyUpdateInSQL() -
prepareBatchedInsertSQL
protected ClientPreparedStatement prepareBatchedInsertSQL(JdbcConnection localConn, int numBatches) throws java.sql.SQLExceptionReturns a prepared statement for the number of batched parameters, used when re-writing batch INSERTs.- Parameters:
localConn
- the connection creating this statementnumBatches
- number of entries in a batch- Returns:
- new ClientPreparedStatement
- Throws:
java.sql.SQLException
- if a database access error occurs or this method is called on a closed PreparedStatement
-
setRetrieveGeneratedKeys
protected void setRetrieveGeneratedKeys(boolean flag) throws java.sql.SQLException- Throws:
java.sql.SQLException
-
getBytesRepresentation
public byte[] getBytesRepresentation(int parameterIndex) throws java.sql.SQLException- Specified by:
getBytesRepresentation
in interfaceJdbcPreparedStatement
- Throws:
java.sql.SQLException
-
getOrigBytes
public byte[] getOrigBytes(int parameterIndex) throws java.sql.SQLException- Specified by:
getOrigBytes
in interfaceJdbcPreparedStatement
- Throws:
java.sql.SQLException
-
getMetaData
public java.sql.ResultSetMetaData getMetaData() throws java.sql.SQLException- Specified by:
getMetaData
in interfacejava.sql.PreparedStatement
- Throws:
java.sql.SQLException
-
isSelectQuery
protected boolean isSelectQuery() throws java.sql.SQLException- Throws:
java.sql.SQLException
-
getParameterMetaData
public java.sql.ParameterMetaData getParameterMetaData() throws java.sql.SQLException- Specified by:
getParameterMetaData
in interfacejava.sql.PreparedStatement
- Throws:
java.sql.SQLException
-
getParseInfo
- Specified by:
getParseInfo
in interfaceJdbcPreparedStatement
-
isNull
public boolean isNull(int paramIndex) throws java.sql.SQLException- Specified by:
isNull
in interfaceJdbcPreparedStatement
- Throws:
java.sql.SQLException
-
realClose
public void realClose(boolean calledExplicitly, boolean closeOpenResults) throws java.sql.SQLExceptionDescription copied from class:StatementImpl
Closes this statement, and frees resources.- Specified by:
realClose
in interfaceJdbcPreparedStatement
- Overrides:
realClose
in classStatementImpl
- Parameters:
calledExplicitly
- was this called from close()?closeOpenResults
- should open result sets be closed?- Throws:
java.sql.SQLException
- if an error occurs
-
getPreparedSql
public java.lang.String getPreparedSql()- Specified by:
getPreparedSql
in interfaceJdbcPreparedStatement
-
getUpdateCount
public int getUpdateCount() throws java.sql.SQLException- Specified by:
getUpdateCount
in interfacejava.sql.Statement
- Overrides:
getUpdateCount
in classStatementImpl
- Throws:
java.sql.SQLException
-
executeLargeUpdate
public long executeLargeUpdate() throws java.sql.SQLException- Specified by:
executeLargeUpdate
in interfacejava.sql.PreparedStatement
- Throws:
java.sql.SQLException
-
getParameterBindings
- Specified by:
getParameterBindings
in interfaceJdbcPreparedStatement
- Throws:
java.sql.SQLException
-
getParameterIndexOffset
protected int getParameterIndexOffset()For calling stored functions, this will be -1 as Connector/J does not count the first '?' parameter marker, but JDBC counts it * as 1, otherwise it will return 0- Returns:
- offset
-
checkBounds
protected void checkBounds(int paramIndex, int parameterIndexOffset) throws java.sql.SQLException- Throws:
java.sql.SQLException
-
getCoreParameterIndex
public final int getCoreParameterIndex(int paramIndex) throws java.sql.SQLException- Throws:
java.sql.SQLException
-
setArray
public void setArray(int i, java.sql.Array x) throws java.sql.SQLException- Specified by:
setArray
in interfacejava.sql.PreparedStatement
- Throws:
java.sql.SQLException
-
setAsciiStream
public void setAsciiStream(int parameterIndex, java.io.InputStream x) throws java.sql.SQLException- Specified by:
setAsciiStream
in interfacejava.sql.PreparedStatement
- Throws:
java.sql.SQLException
-
setAsciiStream
public void setAsciiStream(int parameterIndex, java.io.InputStream x, int length) throws java.sql.SQLException- Specified by:
setAsciiStream
in interfacejava.sql.PreparedStatement
- Throws:
java.sql.SQLException
-
setAsciiStream
public void setAsciiStream(int parameterIndex, java.io.InputStream x, long length) throws java.sql.SQLException- Specified by:
setAsciiStream
in interfacejava.sql.PreparedStatement
- Throws:
java.sql.SQLException
-
setBigDecimal
public void setBigDecimal(int parameterIndex, java.math.BigDecimal x) throws java.sql.SQLException- Specified by:
setBigDecimal
in interfacejava.sql.PreparedStatement
- Throws:
java.sql.SQLException
-
setBinaryStream
public void setBinaryStream(int parameterIndex, java.io.InputStream x) throws java.sql.SQLException- Specified by:
setBinaryStream
in interfacejava.sql.PreparedStatement
- Throws:
java.sql.SQLException
-
setBinaryStream
public void setBinaryStream(int parameterIndex, java.io.InputStream x, int length) throws java.sql.SQLException- Specified by:
setBinaryStream
in interfacejava.sql.PreparedStatement
- Throws:
java.sql.SQLException
-
setBinaryStream
public void setBinaryStream(int parameterIndex, java.io.InputStream x, long length) throws java.sql.SQLException- Specified by:
setBinaryStream
in interfacejava.sql.PreparedStatement
- Throws:
java.sql.SQLException
-
setBlob
public void setBlob(int i, java.sql.Blob x) throws java.sql.SQLException- Specified by:
setBlob
in interfacejava.sql.PreparedStatement
- Throws:
java.sql.SQLException
-
setBlob
public void setBlob(int parameterIndex, java.io.InputStream inputStream) throws java.sql.SQLException- Specified by:
setBlob
in interfacejava.sql.PreparedStatement
- Throws:
java.sql.SQLException
-
setBlob
public void setBlob(int parameterIndex, java.io.InputStream inputStream, long length) throws java.sql.SQLException- Specified by:
setBlob
in interfacejava.sql.PreparedStatement
- Throws:
java.sql.SQLException
-
setBoolean
public void setBoolean(int parameterIndex, boolean x) throws java.sql.SQLException- Specified by:
setBoolean
in interfacejava.sql.PreparedStatement
- Throws:
java.sql.SQLException
-
setByte
public void setByte(int parameterIndex, byte x) throws java.sql.SQLException- Specified by:
setByte
in interfacejava.sql.PreparedStatement
- Throws:
java.sql.SQLException
-
setBytes
public void setBytes(int parameterIndex, byte[] x) throws java.sql.SQLException- Specified by:
setBytes
in interfacejava.sql.PreparedStatement
- Throws:
java.sql.SQLException
-
setBytes
public void setBytes(int parameterIndex, byte[] x, boolean checkForIntroducer, boolean escapeForMBChars) throws java.sql.SQLException- Specified by:
setBytes
in interfaceJdbcPreparedStatement
- Throws:
java.sql.SQLException
-
setBytesNoEscape
public void setBytesNoEscape(int parameterIndex, byte[] parameterAsBytes) throws java.sql.SQLExceptionDescription copied from interface:JdbcPreparedStatement
Used by updatable result sets for refreshRow() because the parameter has already been escaped for updater or inserter prepared statements.- Specified by:
setBytesNoEscape
in interfaceJdbcPreparedStatement
- Parameters:
parameterIndex
- the parameter to set.parameterAsBytes
- the parameter as a string.- Throws:
java.sql.SQLException
- if an error occurs
-
setBytesNoEscapeNoQuotes
public void setBytesNoEscapeNoQuotes(int parameterIndex, byte[] parameterAsBytes) throws java.sql.SQLException- Specified by:
setBytesNoEscapeNoQuotes
in interfaceJdbcPreparedStatement
- Throws:
java.sql.SQLException
-
setCharacterStream
public void setCharacterStream(int parameterIndex, java.io.Reader reader) throws java.sql.SQLException- Specified by:
setCharacterStream
in interfacejava.sql.PreparedStatement
- Throws:
java.sql.SQLException
-
setCharacterStream
public void setCharacterStream(int parameterIndex, java.io.Reader reader, int length) throws java.sql.SQLException- Specified by:
setCharacterStream
in interfacejava.sql.PreparedStatement
- Throws:
java.sql.SQLException
-
setCharacterStream
public void setCharacterStream(int parameterIndex, java.io.Reader reader, long length) throws java.sql.SQLException- Specified by:
setCharacterStream
in interfacejava.sql.PreparedStatement
- Throws:
java.sql.SQLException
-
setClob
public void setClob(int parameterIndex, java.io.Reader reader) throws java.sql.SQLException- Specified by:
setClob
in interfacejava.sql.PreparedStatement
- Throws:
java.sql.SQLException
-
setClob
public void setClob(int parameterIndex, java.io.Reader reader, long length) throws java.sql.SQLException- Specified by:
setClob
in interfacejava.sql.PreparedStatement
- Throws:
java.sql.SQLException
-
setClob
public void setClob(int i, java.sql.Clob x) throws java.sql.SQLException- Specified by:
setClob
in interfacejava.sql.PreparedStatement
- Throws:
java.sql.SQLException
-
setDate
public void setDate(int parameterIndex, java.sql.Date x) throws java.sql.SQLException- Specified by:
setDate
in interfacejava.sql.PreparedStatement
- Throws:
java.sql.SQLException
-
setDate
public void setDate(int parameterIndex, java.sql.Date x, java.util.Calendar cal) throws java.sql.SQLException- Specified by:
setDate
in interfacejava.sql.PreparedStatement
- Throws:
java.sql.SQLException
-
setDouble
public void setDouble(int parameterIndex, double x) throws java.sql.SQLException- Specified by:
setDouble
in interfacejava.sql.PreparedStatement
- Throws:
java.sql.SQLException
-
setFloat
public void setFloat(int parameterIndex, float x) throws java.sql.SQLException- Specified by:
setFloat
in interfacejava.sql.PreparedStatement
- Throws:
java.sql.SQLException
-
setInt
public void setInt(int parameterIndex, int x) throws java.sql.SQLException- Specified by:
setInt
in interfacejava.sql.PreparedStatement
- Throws:
java.sql.SQLException
-
setLong
public void setLong(int parameterIndex, long x) throws java.sql.SQLException- Specified by:
setLong
in interfacejava.sql.PreparedStatement
- Throws:
java.sql.SQLException
-
setBigInteger
public void setBigInteger(int parameterIndex, java.math.BigInteger x) throws java.sql.SQLException- Specified by:
setBigInteger
in interfaceJdbcPreparedStatement
- Throws:
java.sql.SQLException
-
setNCharacterStream
public void setNCharacterStream(int parameterIndex, java.io.Reader value) throws java.sql.SQLException- Specified by:
setNCharacterStream
in interfacejava.sql.PreparedStatement
- Throws:
java.sql.SQLException
-
setNCharacterStream
public void setNCharacterStream(int parameterIndex, java.io.Reader reader, long length) throws java.sql.SQLException- Specified by:
setNCharacterStream
in interfacejava.sql.PreparedStatement
- Throws:
java.sql.SQLException
-
setNClob
public void setNClob(int parameterIndex, java.io.Reader reader) throws java.sql.SQLException- Specified by:
setNClob
in interfacejava.sql.PreparedStatement
- Throws:
java.sql.SQLException
-
setNClob
public void setNClob(int parameterIndex, java.io.Reader reader, long length) throws java.sql.SQLException- Specified by:
setNClob
in interfacejava.sql.PreparedStatement
- Throws:
java.sql.SQLException
-
setNClob
public void setNClob(int parameterIndex, java.sql.NClob value) throws java.sql.SQLException- Specified by:
setNClob
in interfacejava.sql.PreparedStatement
- Throws:
java.sql.SQLException
-
setNString
public void setNString(int parameterIndex, java.lang.String x) throws java.sql.SQLExceptionSet a parameter to a Java String value. The driver converts this to a SQL VARCHAR or LONGVARCHAR value with introducer _utf8 (depending on the arguments size relative to the driver's limits on VARCHARs) when it sends it to the database. If charset is set as utf8, this method just call setString.- Specified by:
setNString
in interfacejava.sql.PreparedStatement
- Parameters:
parameterIndex
- the first parameter is 1...x
- the parameter value- Throws:
java.sql.SQLException
- if a database access error occurs
-
setNull
public void setNull(int parameterIndex, int sqlType) throws java.sql.SQLException- Specified by:
setNull
in interfacejava.sql.PreparedStatement
- Throws:
java.sql.SQLException
-
setNull
public void setNull(int parameterIndex, int sqlType, java.lang.String typeName) throws java.sql.SQLException- Specified by:
setNull
in interfacejava.sql.PreparedStatement
- Throws:
java.sql.SQLException
-
setNull
- Specified by:
setNull
in interfaceJdbcPreparedStatement
- Throws:
java.sql.SQLException
-
setObject
public void setObject(int parameterIndex, java.lang.Object parameterObj) throws java.sql.SQLException- Specified by:
setObject
in interfacejava.sql.PreparedStatement
- Throws:
java.sql.SQLException
-
setObject
public void setObject(int parameterIndex, java.lang.Object parameterObj, int targetSqlType) throws java.sql.SQLException- Specified by:
setObject
in interfacejava.sql.PreparedStatement
- Throws:
java.sql.SQLException
-
setObject
public void setObject(int parameterIndex, java.lang.Object parameterObj, java.sql.SQLType targetSqlType) throws java.sql.SQLException- Specified by:
setObject
in interfacejava.sql.PreparedStatement
- Throws:
java.sql.SQLException
-
setObject
public void setObject(int parameterIndex, java.lang.Object parameterObj, int targetSqlType, int scale) throws java.sql.SQLException- Specified by:
setObject
in interfacejava.sql.PreparedStatement
- Throws:
java.sql.SQLException
-
setObject
public void setObject(int parameterIndex, java.lang.Object x, java.sql.SQLType targetSqlType, int scaleOrLength) throws java.sql.SQLException- Specified by:
setObject
in interfacejava.sql.PreparedStatement
- Throws:
java.sql.SQLException
-
setRef
public void setRef(int i, java.sql.Ref x) throws java.sql.SQLException- Specified by:
setRef
in interfacejava.sql.PreparedStatement
- Throws:
java.sql.SQLException
-
setRowId
public void setRowId(int parameterIndex, java.sql.RowId x) throws java.sql.SQLException- Specified by:
setRowId
in interfacejava.sql.PreparedStatement
- Throws:
java.sql.SQLException
-
setShort
public void setShort(int parameterIndex, short x) throws java.sql.SQLException- Specified by:
setShort
in interfacejava.sql.PreparedStatement
- Throws:
java.sql.SQLException
-
setSQLXML
public void setSQLXML(int parameterIndex, java.sql.SQLXML xmlObject) throws java.sql.SQLException- Specified by:
setSQLXML
in interfacejava.sql.PreparedStatement
- Throws:
java.sql.SQLException
-
setString
public void setString(int parameterIndex, java.lang.String x) throws java.sql.SQLException- Specified by:
setString
in interfacejava.sql.PreparedStatement
- Throws:
java.sql.SQLException
-
setTime
public void setTime(int parameterIndex, java.sql.Time x) throws java.sql.SQLException- Specified by:
setTime
in interfacejava.sql.PreparedStatement
- Throws:
java.sql.SQLException
-
setTime
public void setTime(int parameterIndex, java.sql.Time x, java.util.Calendar cal) throws java.sql.SQLException- Specified by:
setTime
in interfacejava.sql.PreparedStatement
- Throws:
java.sql.SQLException
-
setTimestamp
public void setTimestamp(int parameterIndex, java.sql.Timestamp x) throws java.sql.SQLException- Specified by:
setTimestamp
in interfacejava.sql.PreparedStatement
- Throws:
java.sql.SQLException
-
setTimestamp
public void setTimestamp(int parameterIndex, java.sql.Timestamp x, java.util.Calendar cal) throws java.sql.SQLException- Specified by:
setTimestamp
in interfacejava.sql.PreparedStatement
- Throws:
java.sql.SQLException
-
setTimestamp
public void setTimestamp(int parameterIndex, java.sql.Timestamp x, java.util.Calendar targetCalendar, int fractionalLength) throws java.sql.SQLException- Throws:
java.sql.SQLException
-
setUnicodeStream
@Deprecated public void setUnicodeStream(int parameterIndex, java.io.InputStream x, int length) throws java.sql.SQLExceptionDeprecated.- Specified by:
setUnicodeStream
in interfacejava.sql.PreparedStatement
- Throws:
java.sql.SQLException
-
setURL
public void setURL(int parameterIndex, java.net.URL arg) throws java.sql.SQLException- Specified by:
setURL
in interfacejava.sql.PreparedStatement
- Throws:
java.sql.SQLException
-