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 | Field and Description |
|---|---|
| protected String | |
| protected boolean | batchHasPlainStatements
Does the batch (if any) contain "plain" statements added by Statement.addBatch(String)? |
| private boolean | |
| private boolean | |
| protected MysqlParameterMetadata | |
| private ResultSetMetaData | |
| protected int |
| Access | Constructor and Description |
|---|---|
| protected | ClientPreparedStatement(JdbcConnection
the connection that created us conn, String the database in use when we were created db)Constructor used by server-side prepared statements |
| public | ClientPreparedStatement(JdbcConnection
the connection creating this statement conn, String the SQL for this statement sql, String the database this statement should be issued against db)Constructor for the PreparedStatement class. |
| public | ClientPreparedStatement(JdbcConnection
the connection creating this statement conn, String the SQL for this statement sql, String the database this statement should be issued against db, QueryInfo already created cachedQueryInfo)QueryInfo or null.Creates a new PreparedStatement object. |
| Modifier and Type | Method and Description |
|---|---|
| public void | addBatch()
Implements java. Adds a set of parameters to this |
| public void | addBatch(String
typically this is a SQL sql)INSERT or
UPDATE statementOverrides com. Implements java. Adds the given SQL command to the current list of commands for this
|
| protected void | |
| protected boolean | Returns: true if safe for read-only.Check to see if the statement is safe for read-only replicas after failover. |
| public void | clearBatch()
Overrides com. Implements java. Empties this |
| public void | clearParameters()
Implements java. Clears the current parameter values immediately. |
| protected boolean | |
| public void | doClose(CloseOption...
options indicating how the close was initiated and/or what should be performed during the close options)Overrides com. Implements com. Close this Statement and release resources. |
| public boolean | execute()
Implements java. Executes the SQL statement in this |
| protected long[] | |
| protected long[] | Returns: a list of update countstimeout for the batch execution batchTimeout)Executes the current batch of statements by executing them one-by-one. |
| protected long[] | Returns: update counts in the same fashion as executeBatch()timeout for the batch execution batchTimeout)Rewrites the already prepared statement into a multi-values clause INSERT/REPLACE statement and executes the entire batch using this new statement. |
| protected < extends M extends Message> ResultSetInternalMethodsMessage | Returns: the results as a ResultSetthe max number of rows to return maxRowsToRetrieve, M the packet to send sendPacket, boolean should a 'streaming' result set be created? createStreamingResultSet, boolean is this query doing a SELECT? queryIsSelectOnly, ColumnDefinition use this metadata instead of the one provided on wire metadata, boolean is this a batch query? isBatch)Actually execute the prepared statement. |
| public long | executeLargeUpdate()
Overrides default java. Executes the SQL statement in this |
| protected long[] | Returns: update counts in the same fashion as executeBatch()timeout for the batch execution batchTimeout)Rewrites the already prepared statement into a multi-statement query and executes the entire batch using this new statement. |
| public ResultSet | executeQuery()
Implements java. Executes the SQL query in this |
| public int | executeUpdate()
Implements java. Executes the SQL statement in this |
| protected long | |
| protected long | Returns: the update countbindings object bindings, boolean is it a batched statement? isReallyBatch)Added to allow batch-updates |
| private String | |
| public byte[] | getBytesRepresentation(int parameterIndex)
Implements com.
|
| public final int | |
| protected static ClientPreparedStatement | Returns: ClientPreparedStatementthe connection creating this statement conn, String the SQL for this statement sql, String the database this statement should be issued against db)Creates a prepared statement instance |
| protected static ClientPreparedStatement | Returns: ClientPreparedStatement instancethe connection creating this statement conn, String the SQL for this statement sql, String the database this statement should be issued against db, QueryInfo already created cachedQueryInfo)QueryInfo or null.Creates a prepared statement instance |
| public ResultSetMetaData | getMetaData()
Implements java. Retrieves a |
| public ParameterBindings | |
| protected int | Returns: offsetFor calling stored functions, this will be -1 as Connector/J does not count the first '?' parameter marker, but JDBC counts it * as 1, otherwise it will return 0 |
| public ParameterMetaData | getParameterMetaData()
Implements java. Retrieves the number, types and properties of this
|
| public String | |
| public QueryBindings | |
| public QueryInfo | |
| public int | getUpdateCount()
Overrides com. Implements java. Retrieves the current result as an update count;
if the result is a |
| private void | |
| protected void | |
| private boolean | Returns: true if the query does not produce a result set, false otherwise.Checks if the given SQL query does not return a result set. |
| public boolean | |
| protected boolean | Returns: true if the query produces a result set, false otherwise.Checks if the given SQL query is a result set producing query. |
| protected ClientPreparedStatement | Returns: new ClientPreparedStatementthe connection creating this statement localConn, int number of entries in a batch numBatches)Returns a prepared statement for the number of batched parameters, used when re-writing batch INSERTs. |
| public void | setArray(int
the first parameter is 1, the second is 2, ... i, Array an x)Array object that maps an SQL ARRAY valueImplements java. Sets the designated parameter to the given |
| public void | setAsciiStream(int
the first parameter is 1, the second is 2, ... parameterIndex, InputStream the Java input stream that contains the ASCII parameter value x)Implements java. Sets the designated parameter to the given input stream. |
| public void | setAsciiStream(int
the first parameter is 1, the second is 2, ... parameterIndex, InputStream the Java input stream that contains the ASCII parameter value x, int the number of bytes in the stream length)Implements java. Sets the designated parameter to the given input stream, which will have the specified number of bytes. |
| public void | setAsciiStream(int
the first parameter is 1, the second is 2, ... parameterIndex, InputStream the Java input stream that contains the ASCII parameter value x, long the number of bytes in the stream length)Implements java. Sets the designated parameter to the given input stream, which will have the specified number of bytes. |
| public void | setBigDecimal(int
the first parameter is 1, the second is 2, ... parameterIndex, BigDecimal the parameter value x)Implements java. Sets the designated parameter to the given |
| public void | setBigInteger(int parameterIndex, BigInteger x)
Implements com.
|
| public void | setBinaryStream(int
the first parameter is 1, the second is 2, ... parameterIndex, InputStream the java input stream which contains the binary parameter value x)Implements java. Sets the designated parameter to the given input stream. |
| public void | setBinaryStream(int
the first parameter is 1, the second is 2, ... parameterIndex, InputStream the java input stream which contains the binary parameter value x, int the number of bytes in the stream length)Implements java. Sets the designated parameter to the given input stream, which will have the specified number of bytes. |
| public void | setBinaryStream(int
the first parameter is 1, the second is 2, ... parameterIndex, InputStream the java input stream which contains the binary parameter value x, long the number of bytes in the stream length)Implements java. Sets the designated parameter to the given input stream, which will have the specified number of bytes. |
| public void | setBlob(int
the first parameter is 1, the second is 2, ... i, Blob a x)Blob object that maps an SQL BLOB valueImplements java. Sets the designated parameter to the given |
| public void | setBlob(int
index of the first parameter is 1,
the second is 2, ... parameterIndex, InputStream An object that contains the data to set the parameter
value to. inputStream)Implements java. Sets the designated parameter to a |
| public void | setBlob(int
index of the first parameter is 1,
the second is 2, ... parameterIndex, InputStream An object that contains the data to set the parameter
value to. inputStream, long the number of bytes in the parameter data. length)Implements java. Sets the designated parameter to a |
| public void | setBoolean(int
the first parameter is 1, the second is 2, ... parameterIndex, boolean the parameter value x)Implements java. Sets the designated parameter to the given Java |
| public void | setByte(int
the first parameter is 1, the second is 2, ... parameterIndex, byte the parameter value x)Implements java. Sets the designated parameter to the given Java |
| public void | setBytes(int
the first parameter is 1, the second is 2, ... parameterIndex, byte[] the parameter value x)Implements java. Sets the designated parameter to the given Java array of bytes. |
| public void | setBytes(int parameterIndex, byte[] x, boolean escapeIfNeeded)
Implements com.
|
| public void | setCharacterStream(int
the first parameter is 1, the second is 2, ... parameterIndex, Reader the reader)java.io.Reader object that contains the
Unicode dataImplements java. Sets the designated parameter to the given |
| public void | setCharacterStream(int
the first parameter is 1, the second is 2, ... parameterIndex, Reader the reader, int java.io.Reader object that contains the
Unicode datathe number of characters in the stream length)Implements java. Sets the designated parameter to the given |
| public void | setCharacterStream(int
the first parameter is 1, the second is 2, ... parameterIndex, Reader the reader, long java.io.Reader object that contains the
Unicode datathe number of characters in the stream length)Implements java. Sets the designated parameter to the given |
| public void | setClob(int
index of the first parameter is 1, the second is 2, ... parameterIndex, Reader An object that contains the data to set the parameter value to. reader)Implements java. Sets the designated parameter to a |
| public void | setClob(int
index of the first parameter is 1, the second is 2, ... parameterIndex, Reader An object that contains the data to set the parameter value to. reader, long the number of characters in the parameter data. length)Implements java. Sets the designated parameter to a |
| public void | setClob(int
the first parameter is 1, the second is 2, ... i, Clob a x)Clob object that maps an SQL CLOB valueImplements java. Sets the designated parameter to the given |
| public void | setDate(int
the first parameter is 1, the second is 2, ... parameterIndex, Date the parameter value x)Implements java. Sets the designated parameter to the given |
| public void | setDate(int
the first parameter is 1, the second is 2, ... parameterIndex, Date the parameter value x, Calendar the cal)Calendar object the driver will use
to construct the dateImplements java. Sets the designated parameter to the given |
| public void | setDouble(int
the first parameter is 1, the second is 2, ... parameterIndex, double the parameter value x)Implements java. Sets the designated parameter to the given Java |
| public void | setFloat(int
the first parameter is 1, the second is 2, ... parameterIndex, float the parameter value x)Implements java. Sets the designated parameter to the given Java |
| public void | setInt(int
the first parameter is 1, the second is 2, ... parameterIndex, int the parameter value x)Implements java. Sets the designated parameter to the given Java |
| public void | setLong(int
the first parameter is 1, the second is 2, ... parameterIndex, long the parameter value x)Implements java. Sets the designated parameter to the given Java |
| public void | setNCharacterStream(int
of the first parameter is 1, the second is 2, ... parameterIndex, Reader the parameter value value)Implements java. Sets the designated parameter to a |
| public void | setNCharacterStream(int
of the first parameter is 1, the second is 2, ... parameterIndex, Reader the parameter value reader, long the number of characters in the parameter data. length)Implements java. Sets the designated parameter to a |
| public void | setNClob(int
index of the first parameter is 1, the second is 2, ... parameterIndex, Reader An object that contains the data to set the parameter value to. reader)Implements java. Sets the designated parameter to a |
| public void | setNClob(int
index of the first parameter is 1, the second is 2, ... parameterIndex, Reader An object that contains the data to set the parameter value to. reader, long the number of characters in the parameter data. length)Implements java. Sets the designated parameter to a |
| public void | setNClob(int
of the first parameter is 1, the second is 2, ... parameterIndex, NClob the parameter value value)Implements java. Sets the designated parameter to a |
| public void | setNString(int
the first parameter is 1... parameterIndex, String the parameter value x)Implements java. Set a parameter to a Java String value. |
| public void | setNull(int
the first parameter is 1, the second is 2, ... parameterIndex, int the SQL type code defined in sqlType)java.sql.TypesImplements java. Sets the designated parameter to SQL |
| public void | setNull(int
the first parameter is 1, the second is 2, ... parameterIndex, int a value from sqlType, String java.sql.Typesthe fully-qualified name of an SQL user-defined type;
ignored if the parameter is not a user-defined type or REF typeName)Implements java. Sets the designated parameter to SQL |
| public void | setNull(int parameterIndex, MysqlType mysqlType)
Implements com.
|
| public void | setObject(int
the first parameter is 1, the second is 2, ... parameterIndex, Object the object containing the input parameter value parameterObj)Implements java. Sets the value of the designated parameter using the given object. |
| public void | setObject(int
the first parameter is 1, the second is 2, ... parameterIndex, Object the object containing the input parameter value parameterObj, int the SQL type (as defined in java.sql.Types) to be
sent to the database targetSqlType)Implements java. Sets the value of the designated parameter with the given object. |
| public void | setObject(int
the first parameter is 1, the second is 2, ... parameterIndex, Object the object containing the input parameter value parameterObj, SQLType the SQL type to be sent to the database targetSqlType)Overrides default java. Sets the value of the designated parameter with the given object. |
| public void | setObject(int
the first parameter is 1, the second is 2, ... parameterIndex, Object the object containing the input parameter value parameterObj, int the SQL type (as defined in java.sql.Types) to be
sent to the database. The scale argument may further qualify this type. targetSqlType, int for scale)java.sql.Types.DECIMAL
or java.sql.Types.NUMERIC types,
this is the number of digits after the decimal point. For
Java Object types InputStream and Reader,
this is the length
of the data in the stream or reader. For all other types,
this value will be ignored.Implements java. Sets the value of the designated parameter with the given object. |
| public void | setObject(int
the first parameter is 1, the second is 2, ... parameterIndex, Object the object containing the input parameter value x, SQLType the SQL type to be sent to the database. The
scale argument may further qualify this type. targetSqlType, int for scaleOrLength)java.sql.JDBCType.DECIMAL
or java.sql.JDBCType.NUMERIC types,
this is the number of digits after the decimal point. For
Java Object types InputStream and Reader,
this is the length
of the data in the stream or reader. For all other types,
this value will be ignored.Overrides default java. Sets the value of the designated parameter with the given object. |
| protected int | setOneBatchedParameterSet(PreparedStatement batchedStatement, int batchedParamIndex, Object paramSet)
|
| public void | setRef(int
the first parameter is 1, the second is 2, ... i, Ref an SQL x)REF valueImplements java. Sets the designated parameter to the given
|
| protected void | |
| public void | setRowId(int
the first parameter is 1, the second is 2, ... parameterIndex, RowId the parameter value x)Implements java. Sets the designated parameter to the given |
| public void | setShort(int
the first parameter is 1, the second is 2, ... parameterIndex, short the parameter value x)Implements java. Sets the designated parameter to the given Java |
| public void | setSQLXML(int
index of the first parameter is 1, the second is 2, ... parameterIndex, SQLXML a xmlObject)SQLXML object that maps an SQL XML valueImplements java. Sets the designated parameter to the given |
| public void | setString(int
the first parameter is 1, the second is 2, ... parameterIndex, String the parameter value x)Implements java. Sets the designated parameter to the given Java |
| public void | setTime(int
the first parameter is 1, the second is 2, ... parameterIndex, Time the parameter value x)Implements java. Sets the designated parameter to the given |
| public void | setTime(int
the first parameter is 1, the second is 2, ... parameterIndex, Time the parameter value x, Calendar the cal)Calendar object the driver will use
to construct the timeImplements java. Sets the designated parameter to the given |
| public void | setTimestamp(int
the first parameter is 1, the second is 2, ... parameterIndex, Timestamp the parameter value x)Implements java. Sets the designated parameter to the given |
| public void | setTimestamp(int
the first parameter is 1, the second is 2, ... parameterIndex, Timestamp the parameter value x, Calendar the cal)Calendar object the driver will use
to construct the timestampImplements java. Sets the designated parameter to the given |
| public void | setUnicodeStream(int
the first parameter is 1, the second is 2, ... parameterIndex, InputStream a x, int java.io.InputStream object that contains the
Unicode parameter valuethe number of bytes in the stream length)Implements java.
Deprecated
Sets the designated parameter to the given input stream, which will have the specified number of bytes. |
| public void | setURL(int
the first parameter is 1, the second is 2, ... parameterIndex, URL the arg)java.net.URL object to be setImplements java. Sets the designated parameter to the given |
| public String | Returns: this PreparedStatement represented as a string.Overrides java. Returns this PreparedStatement represented as a string. |