public class PreparedStatement extends StatementImpl implements java.sql.PreparedStatement
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.
| Modifier and Type | Class and Description |
|---|---|
(package private) static class |
PreparedStatement.AppendingBatchVisitor |
class |
PreparedStatement.BatchParams |
(package private) static interface |
PreparedStatement.BatchVisitor |
(package private) class |
PreparedStatement.EmulatedPreparedStatementBindings |
(package private) class |
PreparedStatement.EndPoint |
static class |
PreparedStatement.ParseInfo |
StatementImpl.CancelTask| Modifier and Type | Field and Description |
|---|---|
protected int |
batchCommandIndex
Command index of currently executing batch command.
|
protected java.lang.String |
batchedValuesClause |
protected boolean |
batchHasPlainStatements
Does the batch (if any) contain "plain" statements added by
Statement.addBatch(String)?
|
protected char |
firstCharOfStmt
What is the first character of the prepared statement (used to check for
SELECT vs.
|
protected boolean |
isLoadDataQuery
Is this query a LOAD DATA query?
|
protected boolean[] |
isNull |
protected int |
numberOfExecutions |
protected java.lang.String |
originalSql
The SQL that was passed in to 'prepare'
|
protected int |
parameterCount
The number of parameters in this PreparedStatement
|
protected MysqlParameterMetadata |
parameterMetaData |
protected int[] |
parameterTypes
Only used by statement interceptors at the moment to
provide introspection of bound values
|
protected PreparedStatement.ParseInfo |
parseInfo |
protected int |
rewrittenBatchSize |
protected boolean |
serverSupportsFracSecs |
protected boolean |
useTrueBoolean
Are we using a version of MySQL where we can use 'true' boolean values?
|
protected boolean |
usingAnsiMode |
batchedArgs, batchedGeneratedKeys, cancelTimeoutMutex, charConverter, charEncoding, clearWarningsCalled, connection, connectionId, continueBatchOnError, currentCatalog, doEscapeProcessing, eventSink, generatedKeysResults, holdResultsOpenOverClose, isClosed, lastInsertId, lastQueryIsOnDupKeyUpdate, maxFieldSize, maxRows, ON_DUPLICATE_KEY_UPDATE_CLAUSE, openResults, pedantic, PING_MARKER, pingTarget, pointOfOrigin, profileSQL, results, resultSetConcurrency, resultSetType, retrieveGeneratedKeys, sendFractionalSeconds, statementCounter, statementExecuting, statementId, timeoutInMillis, updateCount, useLegacyDatetimeCode, USES_VARIABLES_FALSE, USES_VARIABLES_TRUE, USES_VARIABLES_UNKNOWN, useUsageAdvisor, version5013OrNewer, warningChain, wasCancelled, wasCancelledByTimeout| Constructor and Description |
|---|
PreparedStatement(MySQLConnection conn,
java.lang.String catalog)
Constructor used by server-side prepared statements
|
PreparedStatement(MySQLConnection conn,
java.lang.String sql,
java.lang.String catalog)
Constructor for the PreparedStatement class.
|
PreparedStatement(MySQLConnection conn,
java.lang.String sql,
java.lang.String catalog,
PreparedStatement.ParseInfo cachedParseInfo)
Creates a new PreparedStatement object.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addBatch()
JDBC 2.0 Add a set of parameters to the batch.
|
void |
addBatch(java.lang.String sql) |
java.lang.String |
asSql() |
java.lang.String |
asSql(boolean quoteStreamsAndUnknowns) |
protected static boolean |
canRewrite(java.lang.String sql,
boolean isOnDuplicateKeyUpdate,
int locationOfOnDuplicateKeyUpdate,
int statementStartPos) |
boolean |
canRewriteAsMultiValueInsertAtSqlLevel() |
protected void |
checkBounds(int paramIndex,
int parameterIndexOffset) |
protected boolean |
checkReadOnlySafeStatement()
Check to see if the statement is safe for read-only slaves after failover.
|
void |
clearBatch()
JDBC 2.0 Make the set of commands in the current batch empty.
|
void |
clearParameters()
In general, parameter values remain in force for repeated used of a
Statement.
|
protected int |
computeBatchSize(int numBatchedArgs)
Computes the optimum number of batched parameter lists to send
without overflowing max_allowed_packet.
|
protected long[] |
computeMaxParameterSetSizeAndBatchSize(int numBatchedArgs)
Computes the maximum parameter set size, and entire batch size given
the number of arguments in the batch.
|
protected boolean |
containsOnDuplicateKeyUpdateInSQL() |
protected void |
detectFractionalSecondsSupport() |
boolean |
execute()
Some prepared statements return multiple results; the execute method
handles these complex statements as well as the simpler form of
statements handled by executeQuery and executeUpdate
|
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 ResultSetInternalMethods |
executeInternal(int maxRowsToRetrieve,
Buffer sendPacket,
boolean createStreamingResultSet,
boolean queryIsSelectOnly,
Field[] metadataFromCache,
boolean isBatch)
Actually execute the prepared statement.
|
long |
executeLargeUpdate()
JDBC 4.2
Same as PreparedStatement.executeUpdate() but returns long instead of int.
|
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()
A Prepared SQL query is executed and its ResultSet is returned
|
int |
executeUpdate()
Execute a SQL INSERT, UPDATE or DELETE statement.
|
protected long |
executeUpdateInternal(boolean clearBatchedGeneratedKeysAndWarnings,
boolean isBatch) |
protected long |
executeUpdateInternal(byte[][] batchedParameterStrings,
java.io.InputStream[] batchedParameterStreams,
boolean[] batchedIsStream,
int[] batchedStreamLengths,
boolean[] batchedIsNull,
boolean isReallyBatch)
Added to allow batch-updates
|
protected Buffer |
fillSendPacket()
Creates the packet that contains the query to be sent to the server.
|
protected Buffer |
fillSendPacket(byte[][] batchedParameterStrings,
java.io.InputStream[] batchedParameterStreams,
boolean[] batchedIsStream,
int[] batchedStreamLengths)
Creates the packet that contains the query to be sent to the server.
|
byte[] |
getBytesRepresentation(int parameterIndex) |
protected byte[] |
getBytesRepresentationForBatch(int parameterIndex,
int commandIndex)
Get bytes representation for a parameter in a statement batch.
|
java.lang.String |
getDateTime(java.lang.String pattern) |
protected static PreparedStatement |
getInstance(MySQLConnection conn,
java.lang.String catalog)
Creates a prepared statement instance -- We need to provide factory-style
methods so we can support both JDBC3 (and older) and JDBC4 runtimes,
otherwise the class verifier complains when it tries to load JDBC4-only
interface classes that are present in JDBC4 method signatures.
|
protected static PreparedStatement |
getInstance(MySQLConnection conn,
java.lang.String sql,
java.lang.String catalog)
Creates a prepared statement instance -- We need to provide factory-style
methods so we can support both JDBC3 (and older) and JDBC4 runtimes,
otherwise the class verifier complains when it tries to load JDBC4-only
interface classes that are present in JDBC4 method signatures.
|
protected static PreparedStatement |
getInstance(MySQLConnection conn,
java.lang.String sql,
java.lang.String catalog,
PreparedStatement.ParseInfo cachedParseInfo)
Creates a prepared statement instance -- We need to provide factory-style
methods so we can support both JDBC3 (and older) and JDBC4 runtimes,
otherwise the class verifier complains when it tries to load JDBC4-only
interface classes that are present in JDBC4 method signatures.
|
protected int |
getLocationOfOnDuplicateKeyUpdate() |
java.sql.ResultSetMetaData |
getMetaData()
The number, types and properties of a ResultSet's columns are provided by
the getMetaData method.
|
java.lang.String |
getNonRewrittenSql() |
ParameterBindings |
getParameterBindings() |
protected int |
getParameterIndexOffset()
For calling stored functions, this will be -1 as we don't really count
the first '?'
|
java.sql.ParameterMetaData |
getParameterMetaData() |
(package private) PreparedStatement.ParseInfo |
getParseInfo() |
java.lang.String |
getPreparedSql() |
int |
getRewrittenBatchSize() |
int |
getUpdateCount()
getUpdateCount returns the current result as an update count, if the
result is a ResultSet or there are no more results, -1 is returned.
|
protected java.lang.String |
getValuesClause() |
(package private) boolean |
isNull(int paramIndex) |
protected boolean |
isSelectQuery() |
protected PreparedStatement |
prepareBatchedInsertSQL(MySQLConnection localConn,
int numBatches)
Returns a prepared statement for the number of batched parameters, used when re-writing batch INSERTs.
|
protected static int |
readFully(java.io.Reader reader,
char[] buf,
int length)
Reads length bytes from reader into buf.
|
protected void |
realClose(boolean calledExplicitly,
boolean closeOpenResults)
Closes this statement, releasing all resources
|
void |
setArray(int i,
java.sql.Array x)
JDBC 2.0 Set an Array parameter.
|
void |
setAsciiStream(int parameterIndex,
java.io.InputStream x) |
void |
setAsciiStream(int parameterIndex,
java.io.InputStream x,
int length)
When a very large ASCII value is input to a LONGVARCHAR parameter, it may
be more practical to send it via a java.io.InputStream.
|
void |
setAsciiStream(int parameterIndex,
java.io.InputStream x,
long length) |
void |
setBigDecimal(int parameterIndex,
java.math.BigDecimal x)
Set a parameter to a java.math.BigDecimal value.
|
void |
setBinaryStream(int parameterIndex,
java.io.InputStream x) |
void |
setBinaryStream(int parameterIndex,
java.io.InputStream x,
int length)
When a very large binary value is input to a LONGVARBINARY parameter, it
may be more practical to send it via a java.io.InputStream.
|
void |
setBinaryStream(int parameterIndex,
java.io.InputStream x,
long length) |
void |
setBlob(int i,
java.sql.Blob x)
JDBC 2.0 Set a BLOB parameter.
|
void |
setBlob(int parameterIndex,
java.io.InputStream inputStream) |
void |
setBlob(int parameterIndex,
java.io.InputStream inputStream,
long length) |
void |
setBoolean(int parameterIndex,
boolean x)
Set a parameter to a Java boolean value.
|
void |
setByte(int parameterIndex,
byte x)
Set a parameter to a Java byte value.
|
void |
setBytes(int parameterIndex,
byte[] x)
Set a parameter to a Java array of bytes.
|
protected void |
setBytes(int parameterIndex,
byte[] x,
boolean checkForIntroducer,
boolean escapeForMBChars) |
protected 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.
|
protected void |
setBytesNoEscapeNoQuotes(int parameterIndex,
byte[] parameterAsBytes) |
void |
setCharacterStream(int parameterIndex,
java.io.Reader reader) |
void |
setCharacterStream(int parameterIndex,
java.io.Reader reader,
int length)
JDBC 2.0 When a very large UNICODE value is input to a LONGVARCHAR
parameter, it may be more practical to send it via a java.io.Reader.
|
void |
setCharacterStream(int parameterIndex,
java.io.Reader reader,
long length) |
void |
setClob(int i,
java.sql.Clob x)
JDBC 2.0 Set a CLOB parameter.
|
void |
setClob(int parameterIndex,
java.io.Reader reader) |
void |
setClob(int parameterIndex,
java.io.Reader reader,
long length) |
void |
setDate(int parameterIndex,
java.sql.Date x)
Set a parameter to a java.sql.Date value.
|
void |
setDate(int parameterIndex,
java.sql.Date x,
java.util.Calendar cal)
Set a parameter to a java.sql.Date value.
|
void |
setDouble(int parameterIndex,
double x)
Set a parameter to a Java double value.
|
void |
setFloat(int parameterIndex,
float x)
Set a parameter to a Java float value.
|
void |
setInt(int parameterIndex,
int x)
Set a parameter to a Java int value.
|
protected void |
setInternal(int paramIndex,
byte[] val) |
protected void |
setInternal(int paramIndex,
java.lang.String val) |
void |
setLong(int parameterIndex,
long x)
Set a parameter to a Java long value.
|
void |
setNCharacterStream(int parameterIndex,
java.io.Reader value) |
void |
setNCharacterStream(int parameterIndex,
java.io.Reader reader,
long length)
JDBC 2.0 When a very large UNICODE value is input to a LONGVARCHAR
parameter, it may be more practical to send it via a java.io.Reader.
|
void |
setNClob(int parameterIndex,
java.io.Reader reader) |
void |
setNClob(int parameterIndex,
java.io.Reader reader,
long length)
JDBC 4.0 Set a NCLOB parameter.
|
void |
setNString(int parameterIndex,
java.lang.String x)
Set a parameter to a Java String value.
|
void |
setNull(int parameterIndex,
int sqlType)
Set a parameter to SQL NULL
Note: You must specify the parameters SQL type (although MySQL ignores it)
|
void |
setNull(int parameterIndex,
int sqlType,
java.lang.String arg)
Set a parameter to SQL NULL.
|
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)
Set the value of a parameter using an object; use the java.lang
equivalent objects for integral values.
|
protected int |
setOneBatchedParameterSet(java.sql.PreparedStatement batchedStatement,
int batchedParamIndex,
java.lang.Object paramSet) |
void |
setRef(int i,
java.sql.Ref x)
JDBC 2.0 Set a REF(<structured-type>) parameter.
|
protected void |
setRetrieveGeneratedKeys(boolean flag) |
void |
setShort(int parameterIndex,
short x)
Set a parameter to a Java short value.
|
void |
setString(int parameterIndex,
java.lang.String x)
Set a parameter to a Java String value.
|
void |
setTime(int parameterIndex,
java.sql.Time x)
Set a parameter to a java.sql.Time value.
|
void |
setTime(int parameterIndex,
java.sql.Time x,
java.util.Calendar cal)
Set a parameter to a java.sql.Time value.
|
void |
setTimestamp(int parameterIndex,
java.sql.Timestamp x)
Set a parameter to a java.sql.Timestamp value.
|
void |
setTimestamp(int parameterIndex,
java.sql.Timestamp x,
java.util.Calendar cal)
Set a parameter to a java.sql.Timestamp value.
|
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.
|
cancel, checkClosed, checkForDml, checkNullOrEmptyQuery, clearWarnings, close, closeAllOpenResults, closeOnCompletion, 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, getCalendarInstanceForSessionOrNew, getConnection, getExceptionInterceptor, getFetchDirection, getFetchSize, getGeneratedKeys, getGeneratedKeysInternal, getGeneratedKeysInternal, getId, getLargeMaxRows, getLargeUpdateCount, getLastInsertID, getLocalInfileInputStream, getLongUpdateCount, getMaxFieldSize, getMaxRows, getMoreResults, getMoreResults, getOnDuplicateKeyLocation, getOpenResultSetCount, getQueryTimeout, getResultSet, getResultSetConcurrency, getResultSetHoldability, getResultSetInternal, getResultSetType, getWarnings, handleExceptionForBatch, hasDeadlockOrTimeoutRolledBackTx, implicitlyCloseAllOpenResults, isClosed, isCloseOnCompletion, isPoolable, isWrapperFor, processMultiCountsAndKeys, removeOpenResultSet, resetCancelledState, setCursorName, setEscapeProcessing, setFetchDirection, setFetchSize, setHoldResultsOpenOverClose, setLargeMaxRows, setLocalInfileInputStream, setMaxFieldSize, setMaxRows, setPingTarget, setPoolable, setQueryTimeout, setResultSetConcurrency, setResultSetType, setupStreamingTimeout, statementBegins, unwrapclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitcancel, clearWarnings, close, closeOnCompletion, execute, execute, execute, execute, executeBatch, executeQuery, executeUpdate, executeUpdate, executeUpdate, executeUpdate, getConnection, getFetchDirection, getFetchSize, getGeneratedKeys, getMaxFieldSize, getMaxRows, getMoreResults, getMoreResults, getQueryTimeout, getResultSet, getResultSetConcurrency, getResultSetHoldability, getResultSetType, getWarnings, isClosed, isCloseOnCompletion, isPoolable, setCursorName, setEscapeProcessing, setFetchDirection, setFetchSize, setMaxFieldSize, setMaxRows, setPoolable, setQueryTimeoutprotected boolean batchHasPlainStatements
protected char firstCharOfStmt
protected boolean isLoadDataQuery
protected boolean[] isNull
protected int numberOfExecutions
protected java.lang.String originalSql
protected int parameterCount
protected MysqlParameterMetadata parameterMetaData
protected int[] parameterTypes
protected PreparedStatement.ParseInfo parseInfo
protected boolean useTrueBoolean
protected boolean usingAnsiMode
protected java.lang.String batchedValuesClause
protected int batchCommandIndex
protected boolean serverSupportsFracSecs
protected int rewrittenBatchSize
public PreparedStatement(MySQLConnection conn, java.lang.String catalog) throws java.sql.SQLException
conn - the connection that created uscatalog - the catalog in use when we were createdjava.sql.SQLException - if an error occurspublic PreparedStatement(MySQLConnection conn, java.lang.String sql, java.lang.String catalog) throws java.sql.SQLException
conn - the connection creating this statementsql - the SQL for this statementcatalog - the catalog/database this statement should be issued againstjava.sql.SQLException - if a database error occurs.public PreparedStatement(MySQLConnection conn, java.lang.String sql, java.lang.String catalog, PreparedStatement.ParseInfo cachedParseInfo) throws java.sql.SQLException
conn - the connection creating this statementsql - the SQL for this statementcatalog - the catalog/database this statement should be issued againstcachedParseInfo - already created parseInfo.java.sql.SQLExceptionprotected static int readFully(java.io.Reader reader,
char[] buf,
int length)
throws java.io.IOException
reader - buf - length - java.io.IOExceptionprotected static PreparedStatement getInstance(MySQLConnection conn, java.lang.String catalog) throws java.sql.SQLException
java.sql.SQLExceptionprotected static PreparedStatement getInstance(MySQLConnection conn, java.lang.String sql, java.lang.String catalog) throws java.sql.SQLException
java.sql.SQLExceptionprotected static PreparedStatement getInstance(MySQLConnection conn, java.lang.String sql, java.lang.String catalog, PreparedStatement.ParseInfo cachedParseInfo) throws java.sql.SQLException
java.sql.SQLExceptionprotected void detectFractionalSecondsSupport()
throws java.sql.SQLException
java.sql.SQLExceptionpublic void addBatch()
throws java.sql.SQLException
addBatch in interface java.sql.PreparedStatementjava.sql.SQLException - if a database-access error occurs.StatementImpl.addBatch(java.lang.String)public void addBatch(java.lang.String sql)
throws java.sql.SQLException
addBatch in interface java.sql.StatementaddBatch in class StatementImpljava.sql.SQLExceptionpublic java.lang.String asSql()
throws java.sql.SQLException
java.sql.SQLExceptionpublic java.lang.String asSql(boolean quoteStreamsAndUnknowns)
throws java.sql.SQLException
java.sql.SQLExceptionpublic void clearBatch()
throws java.sql.SQLException
StatementImplclearBatch in interface java.sql.StatementclearBatch in class StatementImpljava.sql.SQLException - if a database-access error occurs, or the driver does not
support batch statementspublic void clearParameters()
throws java.sql.SQLException
clearParameters in interface java.sql.PreparedStatementjava.sql.SQLException - if a database access error occursprotected boolean checkReadOnlySafeStatement()
throws java.sql.SQLException
java.sql.SQLExceptionpublic boolean execute()
throws java.sql.SQLException
execute in interface java.sql.PreparedStatementjava.sql.SQLException - if a database access error occursprotected long[] executeBatchInternal()
throws java.sql.SQLException
executeBatchInternal in class StatementImpljava.sql.SQLExceptionpublic boolean canRewriteAsMultiValueInsertAtSqlLevel()
throws java.sql.SQLException
java.sql.SQLExceptionprotected int getLocationOfOnDuplicateKeyUpdate()
throws java.sql.SQLException
java.sql.SQLExceptionprotected long[] executePreparedBatchAsMultiStatement(int batchTimeout)
throws java.sql.SQLException
java.sql.SQLExceptionprotected long[] executeBatchedInserts(int batchTimeout)
throws java.sql.SQLException
java.sql.SQLExceptionprotected java.lang.String getValuesClause()
throws java.sql.SQLException
java.sql.SQLExceptionprotected int computeBatchSize(int numBatchedArgs)
throws java.sql.SQLException
numBatchedArgs - java.sql.SQLExceptionprotected long[] computeMaxParameterSetSizeAndBatchSize(int numBatchedArgs)
throws java.sql.SQLException
java.sql.SQLExceptionprotected long[] executeBatchSerially(int batchTimeout)
throws java.sql.SQLException
java.sql.SQLException - if an error occurspublic java.lang.String getDateTime(java.lang.String pattern)
protected ResultSetInternalMethods executeInternal(int maxRowsToRetrieve, Buffer sendPacket, boolean createStreamingResultSet, boolean queryIsSelectOnly, Field[] metadataFromCache, boolean isBatch) throws java.sql.SQLException
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?unpackFields - java.sql.SQLException - if an error occurs.public java.sql.ResultSet executeQuery()
throws java.sql.SQLException
executeQuery in interface java.sql.PreparedStatementjava.sql.SQLException - if a database access error occurspublic int executeUpdate()
throws java.sql.SQLException
executeUpdate in interface java.sql.PreparedStatementjava.sql.SQLException - if a database access error occursprotected long executeUpdateInternal(boolean clearBatchedGeneratedKeysAndWarnings,
boolean isBatch)
throws java.sql.SQLException
java.sql.SQLExceptionprotected long executeUpdateInternal(byte[][] batchedParameterStrings,
java.io.InputStream[] batchedParameterStreams,
boolean[] batchedIsStream,
int[] batchedStreamLengths,
boolean[] batchedIsNull,
boolean isReallyBatch)
throws java.sql.SQLException
batchedParameterStrings - string values used in single statementbatchedParameterStreams - stream values used in single statementbatchedIsStream - flags for streams used in single statementbatchedStreamLengths - lengths of streams to be read.batchedIsNull - flags for parameters that are nulljava.sql.SQLException - if a database error occursprotected boolean containsOnDuplicateKeyUpdateInSQL()
protected Buffer fillSendPacket() throws java.sql.SQLException
java.sql.SQLException - if an error occurs.protected Buffer fillSendPacket(byte[][] batchedParameterStrings, java.io.InputStream[] batchedParameterStreams, boolean[] batchedIsStream, int[] batchedStreamLengths) throws java.sql.SQLException
batchedParameterStrings - the parameters as stringsbatchedParameterStreams - the parameters as streamsbatchedIsStream - is the given parameter a stream?batchedStreamLengths - the lengths of the streams (if appropriate)java.sql.SQLException - if an error occurs.protected PreparedStatement prepareBatchedInsertSQL(MySQLConnection localConn, int numBatches) throws java.sql.SQLException
java.sql.SQLExceptionprotected void setRetrieveGeneratedKeys(boolean flag)
throws java.sql.SQLException
java.sql.SQLExceptionpublic int getRewrittenBatchSize()
public java.lang.String getNonRewrittenSql()
throws java.sql.SQLException
java.sql.SQLExceptionpublic byte[] getBytesRepresentation(int parameterIndex)
throws java.sql.SQLException
parameterIndex - java.sql.SQLExceptionprotected byte[] getBytesRepresentationForBatch(int parameterIndex,
int commandIndex)
throws java.sql.SQLException
parameterIndex - commandIndex - java.sql.SQLExceptionpublic java.sql.ResultSetMetaData getMetaData()
throws java.sql.SQLException
getMetaData in interface java.sql.PreparedStatementjava.sql.SQLException - if a database-access error occurs.protected boolean isSelectQuery()
throws java.sql.SQLException
java.sql.SQLExceptionpublic java.sql.ParameterMetaData getParameterMetaData()
throws java.sql.SQLException
getParameterMetaData in interface java.sql.PreparedStatementjava.sql.SQLExceptiongetParameterMetaData()PreparedStatement.ParseInfo getParseInfo()
boolean isNull(int paramIndex)
throws java.sql.SQLException
java.sql.SQLExceptionprotected void realClose(boolean calledExplicitly,
boolean closeOpenResults)
throws java.sql.SQLException
realClose in class StatementImplcalledExplicitly - was this called by close()?java.sql.SQLException - if an error occurspublic void setArray(int i,
java.sql.Array x)
throws java.sql.SQLException
setArray in interface java.sql.PreparedStatementi - the first parameter is 1, the second is 2, ...x - an object representing an SQL arrayjava.sql.SQLException - because this method is not implemented.NotImplementedpublic void setAsciiStream(int parameterIndex,
java.io.InputStream x,
int length)
throws java.sql.SQLException
Note: This stream object can either be a standard Java stream object or your own subclass that implements the standard interface.
setAsciiStream in interface java.sql.PreparedStatementparameterIndex - the first parameter is 1...x - the parameter valuelength - the number of bytes in the streamjava.sql.SQLException - if a database access error occurspublic void setBigDecimal(int parameterIndex,
java.math.BigDecimal x)
throws java.sql.SQLException
setBigDecimal in interface java.sql.PreparedStatementparameterIndex - the first parameter is 1...x - the parameter valuejava.sql.SQLException - if a database access error occurspublic void setBinaryStream(int parameterIndex,
java.io.InputStream x,
int length)
throws java.sql.SQLException
Note: This stream object can either be a standard Java stream object or your own subclass that implements the standard interface.
setBinaryStream in interface java.sql.PreparedStatementparameterIndex - the first parameter is 1...x - the parameter valuelength - the number of bytes to read from the stream (ignored)java.sql.SQLException - if a database access error occurspublic void setBlob(int parameterIndex,
java.io.InputStream inputStream,
long length)
throws java.sql.SQLException
setBlob in interface java.sql.PreparedStatementjava.sql.SQLExceptionpublic void setBlob(int i,
java.sql.Blob x)
throws java.sql.SQLException
setBlob in interface java.sql.PreparedStatementi - the first parameter is 1, the second is 2, ...x - an object representing a BLOBjava.sql.SQLException - if a database error occurspublic void setBoolean(int parameterIndex,
boolean x)
throws java.sql.SQLException
setBoolean in interface java.sql.PreparedStatementparameterIndex - the first parameter is 1...x - the parameter valuejava.sql.SQLException - if a database access error occurspublic void setByte(int parameterIndex,
byte x)
throws java.sql.SQLException
setByte in interface java.sql.PreparedStatementparameterIndex - the first parameter is 1...x - the parameter valuejava.sql.SQLException - if a database access error occurspublic void setBytes(int parameterIndex,
byte[] x)
throws java.sql.SQLException
setBytes in interface java.sql.PreparedStatementparameterIndex - the first parameter is 1...x - the parameter valuejava.sql.SQLException - if a database access error occursprotected void setBytes(int parameterIndex,
byte[] x,
boolean checkForIntroducer,
boolean escapeForMBChars)
throws java.sql.SQLException
java.sql.SQLExceptionprotected void setBytesNoEscape(int parameterIndex,
byte[] parameterAsBytes)
throws java.sql.SQLException
parameterIndex - the parameter to set.parameterAsBytes - the parameter as a string.java.sql.SQLException - if an error occursprotected void setBytesNoEscapeNoQuotes(int parameterIndex,
byte[] parameterAsBytes)
throws java.sql.SQLException
java.sql.SQLExceptionpublic void setCharacterStream(int parameterIndex,
java.io.Reader reader,
int length)
throws java.sql.SQLException
Note: This stream object can either be a standard Java stream object or your own subclass that implements the standard interface.
setCharacterStream in interface java.sql.PreparedStatementparameterIndex - the first parameter is 1, the second is 2, ...reader - the java reader which contains the UNICODE datalength - the number of characters in the streamjava.sql.SQLException - if a database-access error occurs.public void setClob(int i,
java.sql.Clob x)
throws java.sql.SQLException
setClob in interface java.sql.PreparedStatementi - the first parameter is 1, the second is 2, ...x - an object representing a CLOBjava.sql.SQLException - if a database error occurspublic void setDate(int parameterIndex,
java.sql.Date x)
throws java.sql.SQLException
setDate in interface java.sql.PreparedStatementparameterIndex - the first parameter is 1...x - the parameter valuejava.sql.SQLException - if a database access error occurspublic void setDate(int parameterIndex,
java.sql.Date x,
java.util.Calendar cal)
throws java.sql.SQLException
setDate in interface java.sql.PreparedStatementparameterIndex - the first parameter is 1, the second is 2, ...x - the parameter valuecal - the calendar to interpret the date withjava.sql.SQLException - if a database-access error occurs.public void setDouble(int parameterIndex,
double x)
throws java.sql.SQLException
setDouble in interface java.sql.PreparedStatementparameterIndex - the first parameter is 1...x - the parameter valuejava.sql.SQLException - if a database access error occurspublic void setFloat(int parameterIndex,
float x)
throws java.sql.SQLException
setFloat in interface java.sql.PreparedStatementparameterIndex - the first parameter is 1...x - the parameter valuejava.sql.SQLException - if a database access error occurspublic void setInt(int parameterIndex,
int x)
throws java.sql.SQLException
setInt in interface java.sql.PreparedStatementparameterIndex - the first parameter is 1...x - the parameter valuejava.sql.SQLException - if a database access error occursprotected final void setInternal(int paramIndex,
byte[] val)
throws java.sql.SQLException
java.sql.SQLExceptionprotected void checkBounds(int paramIndex,
int parameterIndexOffset)
throws java.sql.SQLException
java.sql.SQLExceptionprotected final void setInternal(int paramIndex,
java.lang.String val)
throws java.sql.SQLException
java.sql.SQLExceptionpublic void setLong(int parameterIndex,
long x)
throws java.sql.SQLException
setLong in interface java.sql.PreparedStatementparameterIndex - the first parameter is 1...x - the parameter valuejava.sql.SQLException - if a database access error occurspublic void setNull(int parameterIndex,
int sqlType)
throws java.sql.SQLException
Note: You must specify the parameters SQL type (although MySQL ignores it)
setNull in interface java.sql.PreparedStatementparameterIndex - the first parameter is 1, etc...sqlType - the SQL type code defined in java.sql.Typesjava.sql.SQLException - if a database access error occurspublic void setNull(int parameterIndex,
int sqlType,
java.lang.String arg)
throws java.sql.SQLException
Note: You must specify the parameter's SQL type.
setNull in interface java.sql.PreparedStatementparameterIndex - the first parameter is 1, the second is 2, ...sqlType - SQL type code defined by java.sql.Typesarg - argument parameters for nulljava.sql.SQLException - if a database-access error occurs.public void setObject(int parameterIndex,
java.lang.Object parameterObj)
throws java.sql.SQLException
setObject in interface java.sql.PreparedStatementjava.sql.SQLExceptionpublic void setObject(int parameterIndex,
java.lang.Object parameterObj,
int targetSqlType)
throws java.sql.SQLException
setObject in interface java.sql.PreparedStatementparameterIndex - parameterObj - targetSqlType - java.sql.SQLExceptionpublic void setObject(int parameterIndex,
java.lang.Object parameterObj,
int targetSqlType,
int scale)
throws java.sql.SQLException
The given Java object will be converted to the targetSqlType before being sent to the database.
note that this method may be used to pass database-specific abstract data types. This is done by using a Driver-specific Java type and using a targetSqlType of java.sql.Types.OTHER
setObject in interface java.sql.PreparedStatementparameterIndex - the first parameter is 1...parameterObj - the object containing the input parameter valuetargetSqlType - The SQL type to be send to the databasescale - For java.sql.Types.DECIMAL or java.sql.Types.NUMERIC types
this is the number of digits after the decimal. For all other
types this value will be ignored.java.sql.SQLException - if a database access error occursprotected int setOneBatchedParameterSet(java.sql.PreparedStatement batchedStatement,
int batchedParamIndex,
java.lang.Object paramSet)
throws java.sql.SQLException
java.sql.SQLExceptionpublic void setRef(int i,
java.sql.Ref x)
throws java.sql.SQLException
setRef in interface java.sql.PreparedStatementi - the first parameter is 1, the second is 2, ...x - an object representing data of an SQL REF Typejava.sql.SQLException - if a database error occursNotImplementedpublic void setShort(int parameterIndex,
short x)
throws java.sql.SQLException
setShort in interface java.sql.PreparedStatementparameterIndex - the first parameter is 1...x - the parameter valuejava.sql.SQLException - if a database access error occurspublic void setString(int parameterIndex,
java.lang.String x)
throws java.sql.SQLException
setString in interface java.sql.PreparedStatementparameterIndex - the first parameter is 1...x - the parameter valuejava.sql.SQLException - if a database access error occurspublic void setTime(int parameterIndex,
java.sql.Time x,
java.util.Calendar cal)
throws java.sql.SQLException
setTime in interface java.sql.PreparedStatementparameterIndex - the first parameter is 1, the second is 2, ...x - the parameter valuecal - the cal specifying the timezonejava.sql.SQLException - if a database-access error occurs.public void setTime(int parameterIndex,
java.sql.Time x)
throws java.sql.SQLException
setTime in interface java.sql.PreparedStatementparameterIndex - the first parameter is 1...));x - the parameter valuejava.sql.SQLException - if a database access error occurspublic void setTimestamp(int parameterIndex,
java.sql.Timestamp x,
java.util.Calendar cal)
throws java.sql.SQLException
setTimestamp in interface java.sql.PreparedStatementparameterIndex - the first parameter is 1, the second is 2, ...x - the parameter valuecal - the calendar specifying the timezone to usejava.sql.SQLException - if a database-access error occurs.public void setTimestamp(int parameterIndex,
java.sql.Timestamp x)
throws java.sql.SQLException
setTimestamp in interface java.sql.PreparedStatementparameterIndex - the first parameter is 1...x - the parameter valuejava.sql.SQLException - if a database access error occurs@Deprecated
public void setUnicodeStream(int parameterIndex,
java.io.InputStream x,
int length)
throws java.sql.SQLException
Note: This stream object can either be a standard Java stream object or your own subclass that implements the standard interface.
setUnicodeStream in interface java.sql.PreparedStatementparameterIndex - the first parameter is 1...x - the parameter valuelength - the number of bytes to read from the streamjava.sql.SQLException - if a database access error occurspublic void setURL(int parameterIndex,
java.net.URL arg)
throws java.sql.SQLException
setURL in interface java.sql.PreparedStatementjava.sql.SQLExceptionsetURL(int, URL)public java.lang.String toString()
toString in class java.lang.Objectprotected int getParameterIndexOffset()
public void setAsciiStream(int parameterIndex,
java.io.InputStream x)
throws java.sql.SQLException
setAsciiStream in interface java.sql.PreparedStatementjava.sql.SQLExceptionpublic void setAsciiStream(int parameterIndex,
java.io.InputStream x,
long length)
throws java.sql.SQLException
setAsciiStream in interface java.sql.PreparedStatementjava.sql.SQLExceptionpublic void setBinaryStream(int parameterIndex,
java.io.InputStream x)
throws java.sql.SQLException
setBinaryStream in interface java.sql.PreparedStatementjava.sql.SQLExceptionpublic void setBinaryStream(int parameterIndex,
java.io.InputStream x,
long length)
throws java.sql.SQLException
setBinaryStream in interface java.sql.PreparedStatementjava.sql.SQLExceptionpublic void setBlob(int parameterIndex,
java.io.InputStream inputStream)
throws java.sql.SQLException
setBlob in interface java.sql.PreparedStatementjava.sql.SQLExceptionpublic void setCharacterStream(int parameterIndex,
java.io.Reader reader)
throws java.sql.SQLException
setCharacterStream in interface java.sql.PreparedStatementjava.sql.SQLExceptionpublic void setCharacterStream(int parameterIndex,
java.io.Reader reader,
long length)
throws java.sql.SQLException
setCharacterStream in interface java.sql.PreparedStatementjava.sql.SQLExceptionpublic void setClob(int parameterIndex,
java.io.Reader reader)
throws java.sql.SQLException
setClob in interface java.sql.PreparedStatementjava.sql.SQLExceptionpublic void setClob(int parameterIndex,
java.io.Reader reader,
long length)
throws java.sql.SQLException
setClob in interface java.sql.PreparedStatementjava.sql.SQLExceptionpublic void setNCharacterStream(int parameterIndex,
java.io.Reader value)
throws java.sql.SQLException
setNCharacterStream in interface java.sql.PreparedStatementjava.sql.SQLExceptionpublic void setNString(int parameterIndex,
java.lang.String x)
throws java.sql.SQLException
setNString in interface java.sql.PreparedStatementparameterIndex - the first parameter is 1...x - the parameter valuejava.sql.SQLException - if a database access error occurspublic void setNCharacterStream(int parameterIndex,
java.io.Reader reader,
long length)
throws java.sql.SQLException
Note: This stream object can either be a standard Java stream object or your own subclass that implements the standard interface.
setNCharacterStream in interface java.sql.PreparedStatementparameterIndex - the first parameter is 1, the second is 2, ...reader - the java reader which contains the UNICODE datalength - the number of characters in the streamjava.sql.SQLException - if a database-access error occurs.public void setNClob(int parameterIndex,
java.io.Reader reader)
throws java.sql.SQLException
setNClob in interface java.sql.PreparedStatementjava.sql.SQLExceptionpublic void setNClob(int parameterIndex,
java.io.Reader reader,
long length)
throws java.sql.SQLException
setNClob in interface java.sql.PreparedStatementparameterIndex - the first parameter is 1, the second is 2, ...reader - the java reader which contains the UNICODE datalength - the number of characters in the streamjava.sql.SQLException - if a database error occurspublic ParameterBindings getParameterBindings() throws java.sql.SQLException
java.sql.SQLExceptionpublic java.lang.String getPreparedSql()
public int getUpdateCount()
throws java.sql.SQLException
StatementImplgetUpdateCount in interface java.sql.StatementgetUpdateCount in class StatementImpljava.sql.SQLException - if a database access error occursprotected static boolean canRewrite(java.lang.String sql,
boolean isOnDuplicateKeyUpdate,
int locationOfOnDuplicateKeyUpdate,
int statementStartPos)
public long executeLargeUpdate()
throws java.sql.SQLException
java.sql.SQLException