com.mysql.jdbc
Class PreparedStatement

java.lang.Object
  extended by com.mysql.jdbc.StatementImpl
      extended by com.mysql.jdbc.PreparedStatement
All Implemented Interfaces:
java.sql.PreparedStatement, java.sql.Statement, java.sql.Wrapper
Direct Known Subclasses:
CallableStatement, JDBC4PreparedStatement, ServerPreparedStatement

public class PreparedStatement
extends StatementImpl
implements java.sql.PreparedStatement

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.

See Also:
ResultSet, PreparedStatement

Nested Class Summary
(package private)  class PreparedStatement.AppendingBatchVisitor
           
(package private)  class PreparedStatement.BatchParams
           
(package private) static interface PreparedStatement.BatchVisitor
           
(package private)  class PreparedStatement.EmulatedPreparedStatementBindings
           
(package private)  class PreparedStatement.EndPoint
           
(package private)  class PreparedStatement.ParseInfo
           
 
Nested classes/interfaces inherited from class com.mysql.jdbc.StatementImpl
StatementImpl.CancelTask
 
Field Summary
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 hasLimitClause
          Does the SQL for this statement contain a 'limit' clause?
protected  boolean isLoadDataQuery
          Is this query a LOAD DATA query?
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 useTrueBoolean
          Are we using a version of MySQL where we can use 'true' boolean values?
protected  boolean usingAnsiMode
           
 
Fields inherited from class com.mysql.jdbc.StatementImpl
batchedArgs, batchedGeneratedKeys, cancelTimeoutMutex, charConverter, charEncoding, connection, connectionId, continueBatchOnError, currentCatalog, doEscapeProcessing, eventSink, holdResultsOpenOverClose, isClosed, lastInsertId, lastQueryIsOnDupKeyUpdate, maxFieldSize, maxRows, maxRowsChanged, openResults, pedantic, PING_MARKER, pingTarget, pointOfOrigin, profileSQL, results, resultSetConcurrency, resultSetType, retrieveGeneratedKeys, statementCounter, statementId, timeoutInMillis, updateCount, useLegacyDatetimeCode, USES_VARIABLES_FALSE, USES_VARIABLES_TRUE, USES_VARIABLES_UNKNOWN, useUsageAdvisor, warningChain, wasCancelled, wasCancelledByTimeout
 
Fields inherited from interface java.sql.Statement
CLOSE_ALL_RESULTS, CLOSE_CURRENT_RESULT, EXECUTE_FAILED, KEEP_CURRENT_RESULT, NO_GENERATED_KEYS, RETURN_GENERATED_KEYS, SUCCESS_NO_INFO
 
Constructor Summary
PreparedStatement(ConnectionImpl conn, java.lang.String catalog)
          Constructor used by server-side prepared statements
PreparedStatement(ConnectionImpl conn, java.lang.String sql, java.lang.String catalog)
          Constructor for the PreparedStatement class.
PreparedStatement(ConnectionImpl conn, java.lang.String sql, java.lang.String catalog, PreparedStatement.ParseInfo cachedParseInfo)
          Creates a new PreparedStatement object.
 
Method Summary
 void addBatch()
          JDBC 2.0 Add a set of parameters to the batch.
 void addBatch(java.lang.String sql)
          DOCUMENT ME!
protected  java.lang.String asSql()
           
protected  java.lang.String asSql(boolean quoteStreamsAndUnknowns)
           
protected static boolean canRewrite(java.lang.String sql, boolean isOnDuplicateKeyUpdate, int locationOfOnDuplicateKeyUpdate, int statementStartPos)
           
 boolean canRewriteAsMultiValueInsertAtSqlLevel()
           
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.
 void close()
          Closes this prepared statement and releases all resources.
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()
           
 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
 int[] executeBatch()
          JDBC 2.0 Submit a batch of commands to the database for execution.
protected  int[] 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  int[] 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.
protected  int[] 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  int executeUpdate(boolean clearBatchedGeneratedKeysAndWarnings, boolean isBatch)
           
protected  int executeUpdate(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)
          DOCUMENT ME!
protected  byte[] getBytesRepresentationForBatch(int parameterIndex, int commandIndex)
          Get bytes representation for a parameter in a statement batch.
protected static PreparedStatement getInstance(ConnectionImpl 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(ConnectionImpl 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(ConnectionImpl 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()
           
 boolean isClosed()
           
(package private)  boolean isNull(int paramIndex)
           
protected  boolean isSelectQuery()
           
protected  PreparedStatement prepareBatchedInsertSQL(ConnectionImpl 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)
          DOCUMENT ME!
 void setObject(int parameterIndex, java.lang.Object parameterObj, int targetSqlType)
          DOCUMENT ME!
 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.
(package private)  void setResultSetConcurrency(int concurrencyFlag)
          Sets the concurrency for result sets generated by this statement
(package private)  void setResultSetType(int typeFlag)
          Sets the result set type for result sets generated by this statement
protected  void setRetrieveGeneratedKeys(boolean retrieveGeneratedKeys)
          DOCUMENT ME!
 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.
 
Methods inherited from class com.mysql.jdbc.StatementImpl
cancel, checkClosed, checkForDml, checkNullOrEmptyQuery, clearWarnings, closeAllOpenResults, containsOnDuplicateKeyInString, createStreamingResultSet, disableStreamingResults, doPingInstead, enableStreamingResults, execute, execute, execute, execute, executeQuery, executeSimpleNonQuery, executeUpdate, executeUpdate, executeUpdate, executeUpdate, executeUpdate, findStartOfStatement, generatePingResultSet, getBatchedGeneratedKeys, getBatchedGeneratedKeys, getCalendarInstanceForSessionOrNew, getConnection, getExceptionInterceptor, getFetchDirection, getFetchSize, getGeneratedKeys, getGeneratedKeysInternal, getGeneratedKeysInternal, getId, getLastInsertID, getLocalInfileInputStream, getLongUpdateCount, getMaxFieldSize, getMaxRows, getMoreResults, getMoreResults, getOnDuplicateKeyLocation, getOpenResultSetCount, getQueryTimeout, getResultSet, getResultSetConcurrency, getResultSetHoldability, getResultSetInternal, getResultSetType, getWarnings, handleExceptionForBatch, hasDeadlockOrTimeoutRolledBackTx, isPoolable, isWrapperFor, processMultiCountsAndKeys, removeOpenResultSet, resetCancelledState, setCursorName, setEscapeProcessing, setFetchDirection, setFetchSize, setHoldResultsOpenOverClose, setLocalInfileInputStream, setMaxFieldSize, setMaxRows, setPingTarget, setPoolable, setQueryTimeout, unwrap
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.sql.PreparedStatement
setNClob, setRowId, setSQLXML
 
Methods inherited from interface java.sql.Statement
cancel, clearWarnings, execute, execute, execute, execute, executeQuery, executeUpdate, executeUpdate, executeUpdate, executeUpdate, getConnection, getFetchDirection, getFetchSize, getGeneratedKeys, getMaxFieldSize, getMaxRows, getMoreResults, getMoreResults, getQueryTimeout, getResultSet, getResultSetConcurrency, getResultSetHoldability, getResultSetType, getWarnings, isPoolable, setCursorName, setEscapeProcessing, setFetchDirection, setFetchSize, setMaxFieldSize, setMaxRows, setPoolable, setQueryTimeout
 
Methods inherited from interface java.sql.Wrapper
isWrapperFor, unwrap
 

Field Detail

batchHasPlainStatements

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.


firstCharOfStmt

protected char firstCharOfStmt
What is the first character of the prepared statement (used to check for SELECT vs. INSERT/UPDATE/DELETE)


hasLimitClause

protected boolean hasLimitClause
Does the SQL for this statement contain a 'limit' clause?


isLoadDataQuery

protected boolean isLoadDataQuery
Is this query a LOAD DATA query?


numberOfExecutions

protected int numberOfExecutions

originalSql

protected java.lang.String originalSql
The SQL that was passed in to 'prepare'


parameterCount

protected int parameterCount
The number of parameters in this PreparedStatement


parameterMetaData

protected MysqlParameterMetadata parameterMetaData

parameterTypes

protected int[] parameterTypes
Only used by statement interceptors at the moment to provide introspection of bound values


parseInfo

protected PreparedStatement.ParseInfo parseInfo

useTrueBoolean

protected boolean useTrueBoolean
Are we using a version of MySQL where we can use 'true' boolean values?


usingAnsiMode

protected boolean usingAnsiMode

batchedValuesClause

protected java.lang.String batchedValuesClause

rewrittenBatchSize

protected int rewrittenBatchSize
Constructor Detail

PreparedStatement

public PreparedStatement(ConnectionImpl conn,
                         java.lang.String catalog)
                  throws java.sql.SQLException
Constructor used by server-side prepared statements

Parameters:
conn - the connection that created us
catalog - the catalog in use when we were created
Throws:
java.sql.SQLException - if an error occurs

PreparedStatement

public PreparedStatement(ConnectionImpl conn,
                         java.lang.String sql,
                         java.lang.String catalog)
                  throws java.sql.SQLException
Constructor for the PreparedStatement class.

Parameters:
conn - the connection creating this statement
sql - the SQL for this statement
catalog - the catalog/database this statement should be issued against
Throws:
java.sql.SQLException - if a database error occurs.

PreparedStatement

public PreparedStatement(ConnectionImpl conn,
                         java.lang.String sql,
                         java.lang.String catalog,
                         PreparedStatement.ParseInfo cachedParseInfo)
                  throws java.sql.SQLException
Creates a new PreparedStatement object.

Parameters:
conn - the connection creating this statement
sql - the SQL for this statement
catalog - the catalog/database this statement should be issued against
cachedParseInfo - already created parseInfo.
Throws:
java.sql.SQLException - DOCUMENT ME!
Method Detail

readFully

protected static int readFully(java.io.Reader reader,
                               char[] buf,
                               int length)
                        throws java.io.IOException
Reads length bytes from reader into buf. Blocks until enough input is available

Parameters:
reader - DOCUMENT ME!
buf - DOCUMENT ME!
length - DOCUMENT ME!
Returns:
DOCUMENT ME!
Throws:
java.io.IOException - DOCUMENT ME!

getInstance

protected static PreparedStatement getInstance(ConnectionImpl conn,
                                               java.lang.String catalog)
                                        throws java.sql.SQLException
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.

Throws:
java.sql.SQLException

getInstance

protected static PreparedStatement getInstance(ConnectionImpl conn,
                                               java.lang.String sql,
                                               java.lang.String catalog)
                                        throws java.sql.SQLException
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.

Throws:
java.sql.SQLException

getInstance

protected static PreparedStatement getInstance(ConnectionImpl conn,
                                               java.lang.String sql,
                                               java.lang.String catalog,
                                               PreparedStatement.ParseInfo cachedParseInfo)
                                        throws java.sql.SQLException
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.

Throws:
java.sql.SQLException

addBatch

public void addBatch()
              throws java.sql.SQLException
JDBC 2.0 Add a set of parameters to the batch.

Specified by:
addBatch in interface java.sql.PreparedStatement
Throws:
java.sql.SQLException - if a database-access error occurs.
See Also:
StatementImpl.addBatch(java.lang.String)

addBatch

public void addBatch(java.lang.String sql)
              throws java.sql.SQLException
Description copied from class: StatementImpl
DOCUMENT ME!

Specified by:
addBatch in interface java.sql.Statement
Overrides:
addBatch in class StatementImpl
Parameters:
sql - DOCUMENT ME!
Throws:
java.sql.SQLException - DOCUMENT ME!

asSql

protected java.lang.String asSql()
                          throws java.sql.SQLException
Throws:
java.sql.SQLException

asSql

protected java.lang.String asSql(boolean quoteStreamsAndUnknowns)
                          throws java.sql.SQLException
Throws:
java.sql.SQLException

clearBatch

public void clearBatch()
                throws java.sql.SQLException
Description copied from class: StatementImpl
JDBC 2.0 Make the set of commands in the current batch empty. This method is optional.

Specified by:
clearBatch in interface java.sql.Statement
Overrides:
clearBatch in class StatementImpl
Throws:
java.sql.SQLException - if a database-access error occurs, or the driver does not support batch statements

clearParameters

public void clearParameters()
                     throws java.sql.SQLException
In general, parameter values remain in force for repeated used of a Statement. Setting a parameter value automatically clears its previous value. However, in some cases, it is useful to immediately release the resources used by the current parameter values; this can be done by calling clearParameters

Specified by:
clearParameters in interface java.sql.PreparedStatement
Throws:
java.sql.SQLException - if a database access error occurs

close

public void close()
           throws java.sql.SQLException
Closes this prepared statement and releases all resources.

Specified by:
close in interface java.sql.Statement
Overrides:
close in class StatementImpl
Throws:
java.sql.SQLException - if database error occurs.

checkReadOnlySafeStatement

protected boolean checkReadOnlySafeStatement()
                                      throws java.sql.SQLException
Check to see if the statement is safe for read-only slaves after failover.

Returns:
true if safe for read-only.
Throws:
java.sql.SQLException

execute

public boolean execute()
                throws java.sql.SQLException
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

Specified by:
execute in interface java.sql.PreparedStatement
Returns:
true if the next result is a ResultSet; false if it is an update count or there are no more results
Throws:
java.sql.SQLException - if a database access error occurs

executeBatch

public int[] executeBatch()
                   throws java.sql.SQLException
JDBC 2.0 Submit a batch of commands to the database for execution. This method is optional.

Specified by:
executeBatch in interface java.sql.Statement
Overrides:
executeBatch in class StatementImpl
Returns:
an array of update counts containing one element for each command in the batch. The array is ordered according to the order in which commands were inserted into the batch
Throws:
java.sql.SQLException - if a database-access error occurs, or the driver does not support batch statements
java.sql.BatchUpdateException - DOCUMENT ME!

canRewriteAsMultiValueInsertAtSqlLevel

public boolean canRewriteAsMultiValueInsertAtSqlLevel()
                                               throws java.sql.SQLException
Throws:
java.sql.SQLException

getLocationOfOnDuplicateKeyUpdate

protected int getLocationOfOnDuplicateKeyUpdate()

executePreparedBatchAsMultiStatement

protected int[] executePreparedBatchAsMultiStatement(int batchTimeout)
                                              throws java.sql.SQLException
Rewrites the already prepared statement into a multi-statement query of 'statementsPerBatch' values and executes the entire batch using this new statement.

Returns:
update counts in the same fashion as executeBatch()
Throws:
java.sql.SQLException

executeBatchedInserts

protected int[] executeBatchedInserts(int batchTimeout)
                               throws java.sql.SQLException
Rewrites the already prepared statement into a multi-value insert statement of 'statementsPerBatch' values and executes the entire batch using this new statement.

Returns:
update counts in the same fashion as executeBatch()
Throws:
java.sql.SQLException

getValuesClause

protected java.lang.String getValuesClause()
                                    throws java.sql.SQLException
Throws:
java.sql.SQLException

computeBatchSize

protected int computeBatchSize(int numBatchedArgs)
                        throws java.sql.SQLException
Computes the optimum number of batched parameter lists to send without overflowing max_allowed_packet.

Parameters:
numBatchedArgs -
Returns:
Throws:
java.sql.SQLException

computeMaxParameterSetSizeAndBatchSize

protected long[] computeMaxParameterSetSizeAndBatchSize(int numBatchedArgs)
                                                 throws java.sql.SQLException
Computes the maximum parameter set size, and entire batch size given the number of arguments in the batch.

Throws:
java.sql.SQLException

executeBatchSerially

protected int[] executeBatchSerially(int batchTimeout)
                              throws java.sql.SQLException
Executes the current batch of statements by executing them one-by-one.

Returns:
a list of update counts
Throws:
java.sql.SQLException - if an error occurs

executeInternal

protected ResultSetInternalMethods executeInternal(int maxRowsToRetrieve,
                                                   Buffer sendPacket,
                                                   boolean createStreamingResultSet,
                                                   boolean queryIsSelectOnly,
                                                   Field[] metadataFromCache,
                                                   boolean isBatch)
                                            throws java.sql.SQLException
Actually execute the prepared statement. This is here so server-side PreparedStatements can re-use most of the code from this class.

Parameters:
maxRowsToRetrieve - the max number of rows to return
sendPacket - the packet to send
createStreamingResultSet - should a 'streaming' result set be created?
queryIsSelectOnly - is this query doing a SELECT?
unpackFields - DOCUMENT ME!
Returns:
the results as a ResultSet
Throws:
java.sql.SQLException - if an error occurs.

executeQuery

public java.sql.ResultSet executeQuery()
                                throws java.sql.SQLException
A Prepared SQL query is executed and its ResultSet is returned

Specified by:
executeQuery in interface java.sql.PreparedStatement
Returns:
a ResultSet that contains the data produced by the query - never null
Throws:
java.sql.SQLException - if a database access error occurs

executeUpdate

public int executeUpdate()
                  throws java.sql.SQLException
Execute a SQL INSERT, UPDATE or DELETE statement. In addition, SQL statements that return nothing such as SQL DDL statements can be executed.

Specified by:
executeUpdate in interface java.sql.PreparedStatement
Returns:
either the row count for INSERT, UPDATE or DELETE; or 0 for SQL statements that return nothing.
Throws:
java.sql.SQLException - if a database access error occurs

executeUpdate

protected int executeUpdate(boolean clearBatchedGeneratedKeysAndWarnings,
                            boolean isBatch)
                     throws java.sql.SQLException
Throws:
java.sql.SQLException

executeUpdate

protected int executeUpdate(byte[][] batchedParameterStrings,
                            java.io.InputStream[] batchedParameterStreams,
                            boolean[] batchedIsStream,
                            int[] batchedStreamLengths,
                            boolean[] batchedIsNull,
                            boolean isReallyBatch)
                     throws java.sql.SQLException
Added to allow batch-updates

Parameters:
batchedParameterStrings - string values used in single statement
batchedParameterStreams - stream values used in single statement
batchedIsStream - flags for streams used in single statement
batchedStreamLengths - lengths of streams to be read.
batchedIsNull - flags for parameters that are null
Returns:
the update count
Throws:
java.sql.SQLException - if a database error occurs

containsOnDuplicateKeyUpdateInSQL

protected boolean containsOnDuplicateKeyUpdateInSQL()

fillSendPacket

protected Buffer fillSendPacket()
                         throws java.sql.SQLException
Creates the packet that contains the query to be sent to the server.

Returns:
A Buffer filled with the query representing the PreparedStatement.
Throws:
java.sql.SQLException - if an error occurs.

fillSendPacket

protected Buffer fillSendPacket(byte[][] batchedParameterStrings,
                                java.io.InputStream[] batchedParameterStreams,
                                boolean[] batchedIsStream,
                                int[] batchedStreamLengths)
                         throws java.sql.SQLException
Creates the packet that contains the query to be sent to the server.

Parameters:
batchedParameterStrings - the parameters as strings
batchedParameterStreams - the parameters as streams
batchedIsStream - is the given parameter a stream?
batchedStreamLengths - the lengths of the streams (if appropriate)
Returns:
a Buffer filled with the query that represents this statement
Throws:
java.sql.SQLException - if an error occurs.

prepareBatchedInsertSQL

protected PreparedStatement prepareBatchedInsertSQL(ConnectionImpl localConn,
                                                    int numBatches)
                                             throws java.sql.SQLException
Returns a prepared statement for the number of batched parameters, used when re-writing batch INSERTs.

Throws:
java.sql.SQLException

getRewrittenBatchSize

public int getRewrittenBatchSize()

getNonRewrittenSql

public java.lang.String getNonRewrittenSql()

getBytesRepresentation

public byte[] getBytesRepresentation(int parameterIndex)
                              throws java.sql.SQLException
DOCUMENT ME!

Parameters:
parameterIndex - DOCUMENT ME!
Returns:
DOCUMENT ME!
Throws:
java.sql.SQLException - DOCUMENT ME!

getBytesRepresentationForBatch

protected byte[] getBytesRepresentationForBatch(int parameterIndex,
                                                int commandIndex)
                                         throws java.sql.SQLException
Get bytes representation for a parameter in a statement batch.

Parameters:
parameterIndex -
commandIndex -
Returns:
Throws:
java.sql.SQLException

getMetaData

public java.sql.ResultSetMetaData getMetaData()
                                       throws java.sql.SQLException
The number, types and properties of a ResultSet's columns are provided by the getMetaData method.

Specified by:
getMetaData in interface java.sql.PreparedStatement
Returns:
the description of a ResultSet's columns
Throws:
java.sql.SQLException - if a database-access error occurs.

isSelectQuery

protected boolean isSelectQuery()

getParameterMetaData

public java.sql.ParameterMetaData getParameterMetaData()
                                                throws java.sql.SQLException
Specified by:
getParameterMetaData in interface java.sql.PreparedStatement
Throws:
java.sql.SQLException
See Also:
getParameterMetaData()

getParseInfo

PreparedStatement.ParseInfo getParseInfo()

isNull

boolean isNull(int paramIndex)

realClose

protected void realClose(boolean calledExplicitly,
                         boolean closeOpenResults)
                  throws java.sql.SQLException
Closes this statement, releasing all resources

Overrides:
realClose in class StatementImpl
Parameters:
calledExplicitly - was this called by close()?
Throws:
java.sql.SQLException - if an error occurs

setArray

public void setArray(int i,
                     java.sql.Array x)
              throws java.sql.SQLException
JDBC 2.0 Set an Array parameter.

Specified by:
setArray in interface java.sql.PreparedStatement
Parameters:
i - the first parameter is 1, the second is 2, ...
x - an object representing an SQL array
Throws:
java.sql.SQLException - because this method is not implemented.
NotImplemented - DOCUMENT ME!

setAsciiStream

public void setAsciiStream(int parameterIndex,
                           java.io.InputStream x,
                           int length)
                    throws java.sql.SQLException
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. JDBC will read the data from the stream as needed, until it reaches end-of-file. The JDBC driver will do any necessary conversion from ASCII to the database char format.

Note: This stream object can either be a standard Java stream object or your own subclass that implements the standard interface.

Specified by:
setAsciiStream in interface java.sql.PreparedStatement
Parameters:
parameterIndex - the first parameter is 1...
x - the parameter value
length - the number of bytes in the stream
Throws:
java.sql.SQLException - if a database access error occurs

setBigDecimal

public void setBigDecimal(int parameterIndex,
                          java.math.BigDecimal x)
                   throws java.sql.SQLException
Set a parameter to a java.math.BigDecimal value. The driver converts this to a SQL NUMERIC value when it sends it to the database.

Specified by:
setBigDecimal in interface java.sql.PreparedStatement
Parameters:
parameterIndex - the first parameter is 1...
x - the parameter value
Throws:
java.sql.SQLException - if a database access error occurs

setBinaryStream

public void setBinaryStream(int parameterIndex,
                            java.io.InputStream x,
                            int length)
                     throws java.sql.SQLException
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. JDBC will read the data from the stream as needed, until it reaches end-of-file.

Note: This stream object can either be a standard Java stream object or your own subclass that implements the standard interface.

Specified by:
setBinaryStream in interface java.sql.PreparedStatement
Parameters:
parameterIndex - the first parameter is 1...
x - the parameter value
length - the number of bytes to read from the stream (ignored)
Throws:
java.sql.SQLException - if a database access error occurs

setBlob

public void setBlob(int parameterIndex,
                    java.io.InputStream inputStream,
                    long length)
             throws java.sql.SQLException
Specified by:
setBlob in interface java.sql.PreparedStatement
Throws:
java.sql.SQLException

setBlob

public void setBlob(int i,
                    java.sql.Blob x)
             throws java.sql.SQLException
JDBC 2.0 Set a BLOB parameter.

Specified by:
setBlob in interface java.sql.PreparedStatement
Parameters:
i - the first parameter is 1, the second is 2, ...
x - an object representing a BLOB
Throws:
java.sql.SQLException - if a database error occurs

setBoolean

public void setBoolean(int parameterIndex,
                       boolean x)
                throws java.sql.SQLException
Set a parameter to a Java boolean value. The driver converts this to a SQL BIT value when it sends it to the database.

Specified by:
setBoolean in interface java.sql.PreparedStatement
Parameters:
parameterIndex - the first parameter is 1...
x - the parameter value
Throws:
java.sql.SQLException - if a database access error occurs

setByte

public void setByte(int parameterIndex,
                    byte x)
             throws java.sql.SQLException
Set a parameter to a Java byte value. The driver converts this to a SQL TINYINT value when it sends it to the database.

Specified by:
setByte in interface java.sql.PreparedStatement
Parameters:
parameterIndex - the first parameter is 1...
x - the parameter value
Throws:
java.sql.SQLException - if a database access error occurs

setBytes

public void setBytes(int parameterIndex,
                     byte[] x)
              throws java.sql.SQLException
Set a parameter to a Java array of bytes. The driver converts this to a SQL VARBINARY or LONGVARBINARY (depending on the argument's size relative to the driver's limits on VARBINARYs) when it sends it to the database.

Specified by:
setBytes in interface java.sql.PreparedStatement
Parameters:
parameterIndex - the first parameter is 1...
x - the parameter value
Throws:
java.sql.SQLException - if a database access error occurs

setBytes

protected void setBytes(int parameterIndex,
                        byte[] x,
                        boolean checkForIntroducer,
                        boolean escapeForMBChars)
                 throws java.sql.SQLException
Throws:
java.sql.SQLException

setBytesNoEscape

protected void setBytesNoEscape(int parameterIndex,
                                byte[] parameterAsBytes)
                         throws java.sql.SQLException
Used by updatable result sets for refreshRow() because the parameter has already been escaped for updater or inserter prepared statements.

Parameters:
parameterIndex - the parameter to set.
parameterAsBytes - the parameter as a string.
Throws:
java.sql.SQLException - if an error occurs

setBytesNoEscapeNoQuotes

protected void setBytesNoEscapeNoQuotes(int parameterIndex,
                                        byte[] parameterAsBytes)
                                 throws java.sql.SQLException
Throws:
java.sql.SQLException

setCharacterStream

public void setCharacterStream(int parameterIndex,
                               java.io.Reader reader,
                               int length)
                        throws java.sql.SQLException
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. JDBC will read the data from the stream as needed, until it reaches end-of-file. The JDBC driver will do any necessary conversion from UNICODE to the database char format.

Note: This stream object can either be a standard Java stream object or your own subclass that implements the standard interface.

Specified by:
setCharacterStream in interface java.sql.PreparedStatement
Parameters:
parameterIndex - the first parameter is 1, the second is 2, ...
reader - the java reader which contains the UNICODE data
length - the number of characters in the stream
Throws:
java.sql.SQLException - if a database-access error occurs.

setClob

public void setClob(int i,
                    java.sql.Clob x)
             throws java.sql.SQLException
JDBC 2.0 Set a CLOB parameter.

Specified by:
setClob in interface java.sql.PreparedStatement
Parameters:
i - the first parameter is 1, the second is 2, ...
x - an object representing a CLOB
Throws:
java.sql.SQLException - if a database error occurs

setDate

public void setDate(int parameterIndex,
                    java.sql.Date x)
             throws java.sql.SQLException
Set a parameter to a java.sql.Date value. The driver converts this to a SQL DATE value when it sends it to the database.

Specified by:
setDate in interface java.sql.PreparedStatement
Parameters:
parameterIndex - the first parameter is 1...
x - the parameter value
Throws:
java.sql.SQLException - if a database access error occurs

setDate

public void setDate(int parameterIndex,
                    java.sql.Date x,
                    java.util.Calendar cal)
             throws java.sql.SQLException
Set a parameter to a java.sql.Date value. The driver converts this to a SQL DATE value when it sends it to the database.

Specified by:
setDate in interface java.sql.PreparedStatement
Parameters:
parameterIndex - the first parameter is 1, the second is 2, ...
x - the parameter value
cal - the calendar to interpret the date with
Throws:
java.sql.SQLException - if a database-access error occurs.

setDouble

public void setDouble(int parameterIndex,
                      double x)
               throws java.sql.SQLException
Set a parameter to a Java double value. The driver converts this to a SQL DOUBLE value when it sends it to the database

Specified by:
setDouble in interface java.sql.PreparedStatement
Parameters:
parameterIndex - the first parameter is 1...
x - the parameter value
Throws:
java.sql.SQLException - if a database access error occurs

setFloat

public void setFloat(int parameterIndex,
                     float x)
              throws java.sql.SQLException
Set a parameter to a Java float value. The driver converts this to a SQL FLOAT value when it sends it to the database.

Specified by:
setFloat in interface java.sql.PreparedStatement
Parameters:
parameterIndex - the first parameter is 1...
x - the parameter value
Throws:
java.sql.SQLException - if a database access error occurs

setInt

public void setInt(int parameterIndex,
                   int x)
            throws java.sql.SQLException
Set a parameter to a Java int value. The driver converts this to a SQL INTEGER value when it sends it to the database.

Specified by:
setInt in interface java.sql.PreparedStatement
Parameters:
parameterIndex - the first parameter is 1...
x - the parameter value
Throws:
java.sql.SQLException - if a database access error occurs

setInternal

protected final void setInternal(int paramIndex,
                                 byte[] val)
                          throws java.sql.SQLException
Throws:
java.sql.SQLException

setInternal

protected final void setInternal(int paramIndex,
                                 java.lang.String val)
                          throws java.sql.SQLException
Throws:
java.sql.SQLException

setLong

public void setLong(int parameterIndex,
                    long x)
             throws java.sql.SQLException
Set a parameter to a Java long value. The driver converts this to a SQL BIGINT value when it sends it to the database.

Specified by:
setLong in interface java.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
Set a parameter to SQL NULL

Note: You must specify the parameters SQL type (although MySQL ignores it)

Specified by:
setNull in interface java.sql.PreparedStatement
Parameters:
parameterIndex - the first parameter is 1, etc...
sqlType - the SQL type code defined in java.sql.Types
Throws:
java.sql.SQLException - if a database access error occurs

setNull

public void setNull(int parameterIndex,
                    int sqlType,
                    java.lang.String arg)
             throws java.sql.SQLException
Set a parameter to SQL NULL.

Note: You must specify the parameter's SQL type.

Specified by:
setNull in interface java.sql.PreparedStatement
Parameters:
parameterIndex - the first parameter is 1, the second is 2, ...
sqlType - SQL type code defined by java.sql.Types
arg - argument parameters for null
Throws:
java.sql.SQLException - if a database-access error occurs.

setObject

public void setObject(int parameterIndex,
                      java.lang.Object parameterObj)
               throws java.sql.SQLException
DOCUMENT ME!

Specified by:
setObject in interface java.sql.PreparedStatement
Parameters:
parameterIndex - DOCUMENT ME!
parameterObj - DOCUMENT ME!
Throws:
java.sql.SQLException - DOCUMENT ME!

setObject

public void setObject(int parameterIndex,
                      java.lang.Object parameterObj,
                      int targetSqlType)
               throws java.sql.SQLException
DOCUMENT ME!

Specified by:
setObject in interface java.sql.PreparedStatement
Parameters:
parameterIndex - DOCUMENT ME!
parameterObj - DOCUMENT ME!
targetSqlType - DOCUMENT ME!
Throws:
java.sql.SQLException - DOCUMENT ME!

setObject

public void setObject(int parameterIndex,
                      java.lang.Object parameterObj,
                      int targetSqlType,
                      int scale)
               throws java.sql.SQLException
Set the value of a parameter using an object; use the java.lang equivalent objects for integral values.

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

Specified by:
setObject in interface java.sql.PreparedStatement
Parameters:
parameterIndex - the first parameter is 1...
parameterObj - the object containing the input parameter value
targetSqlType - The SQL type to be send to the database
scale - 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.
Throws:
java.sql.SQLException - if a database access error occurs

setOneBatchedParameterSet

protected int setOneBatchedParameterSet(java.sql.PreparedStatement batchedStatement,
                                        int batchedParamIndex,
                                        java.lang.Object paramSet)
                                 throws java.sql.SQLException
Throws:
java.sql.SQLException

setRef

public void setRef(int i,
                   java.sql.Ref x)
            throws java.sql.SQLException
JDBC 2.0 Set a REF(<structured-type>) parameter.

Specified by:
setRef in interface java.sql.PreparedStatement
Parameters:
i - the first parameter is 1, the second is 2, ...
x - an object representing data of an SQL REF Type
Throws:
java.sql.SQLException - if a database error occurs
NotImplemented - DOCUMENT ME!

setResultSetConcurrency

void setResultSetConcurrency(int concurrencyFlag)
Sets the concurrency for result sets generated by this statement

Overrides:
setResultSetConcurrency in class StatementImpl
Parameters:
concurrencyFlag - DOCUMENT ME!

setResultSetType

void setResultSetType(int typeFlag)
Sets the result set type for result sets generated by this statement

Overrides:
setResultSetType in class StatementImpl
Parameters:
typeFlag - DOCUMENT ME!

setRetrieveGeneratedKeys

protected void setRetrieveGeneratedKeys(boolean retrieveGeneratedKeys)
DOCUMENT ME!

Parameters:
retrieveGeneratedKeys -

setShort

public void setShort(int parameterIndex,
                     short x)
              throws java.sql.SQLException
Set a parameter to a Java short value. The driver converts this to a SQL SMALLINT value when it sends it to the database.

Specified by:
setShort in interface java.sql.PreparedStatement
Parameters:
parameterIndex - the first parameter is 1...
x - the parameter value
Throws:
java.sql.SQLException - if a database access error occurs

setString

public void setString(int parameterIndex,
                      java.lang.String x)
               throws java.sql.SQLException
Set a parameter to a Java String value. The driver converts this to a SQL VARCHAR or LONGVARCHAR value (depending on the arguments size relative to the driver's limits on VARCHARs) when it sends it to the database.

Specified by:
setString in interface java.sql.PreparedStatement
Parameters:
parameterIndex - the first parameter is 1...
x - the parameter value
Throws:
java.sql.SQLException - if a database access error occurs

setTime

public void setTime(int parameterIndex,
                    java.sql.Time x,
                    java.util.Calendar cal)
             throws java.sql.SQLException
Set a parameter to a java.sql.Time value. The driver converts this to a SQL TIME value when it sends it to the database.

Specified by:
setTime in interface java.sql.PreparedStatement
Parameters:
parameterIndex - the first parameter is 1, the second is 2, ...
x - the parameter value
cal - the cal specifying the timezone
Throws:
java.sql.SQLException - if a database-access error occurs.

setTime

public void setTime(int parameterIndex,
                    java.sql.Time x)
             throws java.sql.SQLException
Set a parameter to a java.sql.Time value. The driver converts this to a SQL TIME value when it sends it to the database.

Specified by:
setTime in interface java.sql.PreparedStatement
Parameters:
parameterIndex - the first parameter is 1...));
x - the parameter value
Throws:
java.sql.SQLException - if a database access error occurs

setTimestamp

public void setTimestamp(int parameterIndex,
                         java.sql.Timestamp x,
                         java.util.Calendar cal)
                  throws java.sql.SQLException
Set a parameter to a java.sql.Timestamp value. The driver converts this to a SQL TIMESTAMP value when it sends it to the database.

Specified by:
setTimestamp in interface java.sql.PreparedStatement
Parameters:
parameterIndex - the first parameter is 1, the second is 2, ...
x - the parameter value
cal - the calendar specifying the timezone to use
Throws:
java.sql.SQLException - if a database-access error occurs.

setTimestamp

public void setTimestamp(int parameterIndex,
                         java.sql.Timestamp x)
                  throws java.sql.SQLException
Set a parameter to a java.sql.Timestamp value. The driver converts this to a SQL TIMESTAMP value when it sends it to the database.

Specified by:
setTimestamp in interface java.sql.PreparedStatement
Parameters:
parameterIndex - the first parameter is 1...
x - the parameter value
Throws:
java.sql.SQLException - if a database access error occurs

setUnicodeStream

public void setUnicodeStream(int parameterIndex,
                             java.io.InputStream x,
                             int length)
                      throws java.sql.SQLException
Deprecated. 

When a very large Unicode value is input to a LONGVARCHAR parameter, it may be more practical to send it via a java.io.InputStream. JDBC will read the data from the stream as needed, until it reaches end-of-file. The JDBC driver will do any necessary conversion from UNICODE to the database char format.

Note: This stream object can either be a standard Java stream object or your own subclass that implements the standard interface.

Specified by:
setUnicodeStream in interface java.sql.PreparedStatement
Parameters:
parameterIndex - the first parameter is 1...
x - the parameter value
length - the number of bytes to read from the stream
Throws:
java.sql.SQLException - if a database access error occurs

setURL

public void setURL(int parameterIndex,
                   java.net.URL arg)
            throws java.sql.SQLException
Specified by:
setURL in interface java.sql.PreparedStatement
Throws:
java.sql.SQLException
See Also:
setURL(int, URL)

toString

public java.lang.String toString()
Returns this PreparedStatement represented as a string.

Overrides:
toString in class java.lang.Object
Returns:
this PreparedStatement represented as a string.

isClosed

public boolean isClosed()
                 throws java.sql.SQLException
Specified by:
isClosed in interface java.sql.Statement
Overrides:
isClosed in class StatementImpl
Throws:
java.sql.SQLException

getParameterIndexOffset

protected int getParameterIndexOffset()
For calling stored functions, this will be -1 as we don't really count the first '?' parameter marker, it's only syntax, but JDBC counts it as #1, otherwise it will return 0


setAsciiStream

public void setAsciiStream(int parameterIndex,
                           java.io.InputStream x)
                    throws java.sql.SQLException
Specified by:
setAsciiStream in interface java.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 interface java.sql.PreparedStatement
Throws:
java.sql.SQLException

setBinaryStream

public void setBinaryStream(int parameterIndex,
                            java.io.InputStream x)
                     throws java.sql.SQLException
Specified by:
setBinaryStream in interface java.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 interface java.sql.PreparedStatement
Throws:
java.sql.SQLException

setBlob

public void setBlob(int parameterIndex,
                    java.io.InputStream inputStream)
             throws java.sql.SQLException
Specified by:
setBlob in interface java.sql.PreparedStatement
Throws:
java.sql.SQLException

setCharacterStream

public void setCharacterStream(int parameterIndex,
                               java.io.Reader reader)
                        throws java.sql.SQLException
Specified by:
setCharacterStream in interface java.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 interface java.sql.PreparedStatement
Throws:
java.sql.SQLException

setClob

public void setClob(int parameterIndex,
                    java.io.Reader reader)
             throws java.sql.SQLException
Specified by:
setClob in interface java.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 interface java.sql.PreparedStatement
Throws:
java.sql.SQLException

setNCharacterStream

public void setNCharacterStream(int parameterIndex,
                                java.io.Reader value)
                         throws java.sql.SQLException
Specified by:
setNCharacterStream in interface java.sql.PreparedStatement
Throws:
java.sql.SQLException

setNString

public void setNString(int parameterIndex,
                       java.lang.String x)
                throws java.sql.SQLException
Set 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 interface java.sql.PreparedStatement
Parameters:
parameterIndex - the first parameter is 1...
x - the parameter value
Throws:
java.sql.SQLException - if a database access error occurs

setNCharacterStream

public void setNCharacterStream(int parameterIndex,
                                java.io.Reader reader,
                                long length)
                         throws java.sql.SQLException
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. JDBC will read the data from the stream as needed, until it reaches end-of-file. The JDBC driver will do any necessary conversion from UNICODE to the database char format.

Note: This stream object can either be a standard Java stream object or your own subclass that implements the standard interface.

Specified by:
setNCharacterStream in interface java.sql.PreparedStatement
Parameters:
parameterIndex - the first parameter is 1, the second is 2, ...
reader - the java reader which contains the UNICODE data
length - the number of characters in the stream
Throws:
java.sql.SQLException - if a database-access error occurs.

setNClob

public void setNClob(int parameterIndex,
                     java.io.Reader reader)
              throws java.sql.SQLException
Specified by:
setNClob in interface java.sql.PreparedStatement
Throws:
java.sql.SQLException

setNClob

public void setNClob(int parameterIndex,
                     java.io.Reader reader,
                     long length)
              throws java.sql.SQLException
JDBC 4.0 Set a NCLOB parameter.

Specified by:
setNClob in interface java.sql.PreparedStatement
Parameters:
parameterIndex - the first parameter is 1, the second is 2, ...
reader - the java reader which contains the UNICODE data
length - the number of characters in the stream
Throws:
java.sql.SQLException - if a database error occurs

getParameterBindings

public ParameterBindings getParameterBindings()
                                       throws java.sql.SQLException
Throws:
java.sql.SQLException

getPreparedSql

public java.lang.String getPreparedSql()

getUpdateCount

public int getUpdateCount()
                   throws java.sql.SQLException
Description copied from class: StatementImpl
getUpdateCount returns the current result as an update count, if the result is a ResultSet or there are no more results, -1 is returned. It should only be called once per result.

Specified by:
getUpdateCount in interface java.sql.Statement
Overrides:
getUpdateCount in class StatementImpl
Returns:
the current result as an update count.
Throws:
java.sql.SQLException - if a database access error occurs

canRewrite

protected static boolean canRewrite(java.lang.String sql,
                                    boolean isOnDuplicateKeyUpdate,
                                    int locationOfOnDuplicateKeyUpdate,
                                    int statementStartPos)