Class JdbcPreparedStatement
- java.lang.Object
-
- org.h2.message.TraceObject
-
- org.h2.jdbc.JdbcStatement
-
- org.h2.jdbc.JdbcPreparedStatement
-
- All Implemented Interfaces:
java.lang.AutoCloseable,java.sql.PreparedStatement,java.sql.Statement,java.sql.Wrapper,JdbcStatementBackwardsCompat
- Direct Known Subclasses:
JdbcCallableStatement
public class JdbcPreparedStatement extends JdbcStatement implements java.sql.PreparedStatement
Represents a prepared statement.Thread safety: the prepared statement is not thread-safe. If the same prepared statement is used by multiple threads access to it must be synchronized. The single synchronized block must include assignment of parameters, execution of the command and all operations with its result.
synchronized (prep) { prep.setInt(1, 10); try (ResultSet rs = prep.executeQuery()) { while (rs.next) { // Do something } } } synchronized (prep) { prep.setInt(1, 15); updateCount = prep.executeUpdate(); }
-
-
Field Summary
Fields Modifier and Type Field Description private MergedResultbatchIdentitiesprivate java.util.ArrayList<Value[]>batchParametersprivate java.util.HashMap<java.lang.String,java.lang.Integer>cachedColumnLabelMapprotected CommandInterfacecommandprivate java.lang.ObjectgeneratedKeysRequest-
Fields inherited from class org.h2.jdbc.JdbcStatement
conn, fetchSize, generatedKeys, maxRows, resultSet, resultSetConcurrency, resultSetType, session, updateCount
-
Fields inherited from class org.h2.message.TraceObject
ARRAY, BLOB, CALLABLE_STATEMENT, CLOB, CONNECTION, DATA_SOURCE, DATABASE_META_DATA, PARAMETER_META_DATA, PREPARED_STATEMENT, RESULT_SET, RESULT_SET_META_DATA, SAVEPOINT, SQLXML, STATEMENT, trace, XA_DATA_SOURCE, XID
-
-
Constructor Summary
Constructors Constructor Description JdbcPreparedStatement(JdbcConnection conn, java.lang.String sql, int id, int resultSetType, int resultSetConcurrency, java.lang.Object generatedKeysRequest)
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidaddBatch()Adds the current settings to the batch.voidaddBatch(java.lang.String sql)Calling this method is not legal on a PreparedStatement.voidclearBatch()Clears the batch.voidclearParameters()Clears all parameters.voidclose()Closes this statement.booleanexecute()Executes an arbitrary statement.int[]executeBatch()Executes the batch.private longexecuteBatchElement(Value[] set, java.sql.SQLException exception)long[]executeLargeBatch()Executes the batch.longexecuteLargeUpdate()Executes a statement (insert, update, delete, create, drop) and returns the update count.java.sql.ResultSetexecuteQuery()Executes a query (select statement) and returns the result set.java.sql.ResultSetexecuteQuery(java.lang.String sql)Calling this method is not legal on a PreparedStatement.intexecuteUpdate()Executes a statement (insert, update, delete, create, drop) and returns the update count.private longexecuteUpdateInternal()java.sql.ResultSetgetGeneratedKeys()Return a result set with generated keys from the latest executed command or an empty result set if keys were not generated or were not requested withStatement.RETURN_GENERATED_KEYS, column indexes, or column names.java.sql.ResultSetMetaDatagetMetaData()Gets the result set metadata of the query returned when the statement is executed.java.sql.ParameterMetaDatagetParameterMetaData()Get the parameter meta data of this prepared statement.voidsetArray(int parameterIndex, java.sql.Array x)Sets the value of a parameter as an Array.voidsetAsciiStream(int parameterIndex, java.io.InputStream x)Sets the value of a parameter as an ASCII stream.voidsetAsciiStream(int parameterIndex, java.io.InputStream x, int length)Sets the value of a parameter as an ASCII stream.voidsetAsciiStream(int parameterIndex, java.io.InputStream x, long length)Sets the value of a parameter as an ASCII stream.voidsetBigDecimal(int parameterIndex, java.math.BigDecimal x)Sets the value of a parameter.voidsetBinaryStream(int parameterIndex, java.io.InputStream x)Sets the value of a parameter as an input stream.voidsetBinaryStream(int parameterIndex, java.io.InputStream x, int length)Sets the value of a parameter as an input stream.voidsetBinaryStream(int parameterIndex, java.io.InputStream x, long length)Sets the value of a parameter as an input stream.voidsetBlob(int parameterIndex, java.io.InputStream x)Sets the value of a parameter as a Blob.voidsetBlob(int parameterIndex, java.io.InputStream x, long length)Sets the value of a parameter as a Blob.voidsetBlob(int parameterIndex, java.sql.Blob x)Sets the value of a parameter as a Blob.voidsetBoolean(int parameterIndex, boolean x)Sets the value of a parameter.voidsetByte(int parameterIndex, byte x)Sets the value of a parameter.voidsetBytes(int parameterIndex, byte[] x)Sets the value of a parameter as a byte array.(package private) voidsetCachedColumnLabelMap(java.util.HashMap<java.lang.String,java.lang.Integer> cachedColumnLabelMap)Cache the column labels (looking up the column index can sometimes show up on the performance profile).voidsetCharacterStream(int parameterIndex, java.io.Reader x)Sets the value of a parameter as a character stream.voidsetCharacterStream(int parameterIndex, java.io.Reader x, int length)Sets the value of a parameter as a character stream.voidsetCharacterStream(int parameterIndex, java.io.Reader x, long length)Sets the value of a parameter as a character stream.voidsetClob(int parameterIndex, java.io.Reader x)Sets the value of a parameter as a Clob.voidsetClob(int parameterIndex, java.io.Reader x, long length)Sets the value of a parameter as a Clob.voidsetClob(int parameterIndex, java.sql.Clob x)Sets the value of a parameter as a Clob.voidsetDate(int parameterIndex, java.sql.Date x)Sets the value of a parameter.voidsetDate(int parameterIndex, java.sql.Date x, java.util.Calendar calendar)Sets the date using a specified time zone.voidsetDouble(int parameterIndex, double x)Sets the value of a parameter.voidsetFloat(int parameterIndex, float x)Sets the value of a parameter.voidsetInt(int parameterIndex, int x)Sets the value of a parameter.voidsetLong(int parameterIndex, long x)Sets the value of a parameter.voidsetNCharacterStream(int parameterIndex, java.io.Reader x)Sets the value of a parameter as a character stream.voidsetNCharacterStream(int parameterIndex, java.io.Reader x, long length)Sets the value of a parameter as a character stream.voidsetNClob(int parameterIndex, java.io.Reader x)Sets the value of a parameter as a Clob.voidsetNClob(int parameterIndex, java.io.Reader x, long length)Sets the value of a parameter as a Clob.voidsetNClob(int parameterIndex, java.sql.NClob x)Sets the value of a parameter as a Clob.voidsetNString(int parameterIndex, java.lang.String x)Sets the value of a parameter.voidsetNull(int parameterIndex, int sqlType)Sets a parameter to null.voidsetNull(int parameterIndex, int sqlType, java.lang.String typeName)Sets a parameter to null.voidsetObject(int parameterIndex, java.lang.Object x)Sets the value of a parameter.voidsetObject(int parameterIndex, java.lang.Object x, int targetSqlType)Sets the value of a parameter.voidsetObject(int parameterIndex, java.lang.Object x, int targetSqlType, int scale)Sets the value of a parameter.voidsetObject(int parameterIndex, java.lang.Object x, java.sql.SQLType targetSqlType)Sets the value of a parameter.voidsetObject(int parameterIndex, java.lang.Object x, java.sql.SQLType targetSqlType, int scaleOrLength)Sets the value of a parameter.private voidsetObjectWithType(int parameterIndex, java.lang.Object x, int type)private voidsetParameter(int parameterIndex, Value value)voidsetRef(int parameterIndex, java.sql.Ref x)[Not supported] Sets the value of a column as a reference.voidsetRowId(int parameterIndex, java.sql.RowId x)[Not supported] Sets the value of a parameter as a row id.voidsetShort(int parameterIndex, short x)Sets the value of a parameter.voidsetSQLXML(int parameterIndex, java.sql.SQLXML x)Sets the value of a parameter as a SQLXML.voidsetString(int parameterIndex, java.lang.String x)Sets the value of a parameter.voidsetTime(int parameterIndex, java.sql.Time x)Sets the value of a parameter.voidsetTime(int parameterIndex, java.sql.Time x, java.util.Calendar calendar)Sets the time using a specified time zone.voidsetTimestamp(int parameterIndex, java.sql.Timestamp x)Sets the value of a parameter.voidsetTimestamp(int parameterIndex, java.sql.Timestamp x, java.util.Calendar calendar)Sets the timestamp using a specified time zone.voidsetUnicodeStream(int parameterIndex, java.io.InputStream x, int length)Deprecated.since JDBC 2.0, use setCharacterStreamvoidsetURL(int parameterIndex, java.net.URL x)[Not supported]java.lang.StringtoString()INTERNAL-
Methods inherited from class org.h2.jdbc.JdbcStatement
cancel, checkClosed, clearWarnings, closeIfCloseOnCompletion, closeOldResultSet, closeOnCompletion, enquoteIdentifier, execute, execute, execute, execute, executeLargeUpdate, executeLargeUpdate, executeLargeUpdate, executeLargeUpdate, executeUpdate, executeUpdate, executeUpdate, executeUpdate, getConnection, getFetchDirection, getFetchSize, getLargeMaxRows, getLargeUpdateCount, getMaxFieldSize, getMaxRows, getMoreResults, getMoreResults, getQueryTimeout, getResultSet, getResultSetConcurrency, getResultSetHoldability, getResultSetType, getUpdateCount, getWarnings, isCancelled, isClosed, isCloseOnCompletion, isPoolable, isSimpleIdentifier, isWrapperFor, onLazyResultSetClose, setCursorName, setEscapeProcessing, setExecutingStatement, setFetchDirection, setFetchSize, setLargeMaxRows, setMaxFieldSize, setMaxRows, setPoolable, setQueryTimeout, unwrap
-
Methods inherited from class org.h2.message.TraceObject
debugCode, debugCodeAssign, debugCodeCall, debugCodeCall, debugCodeCall, getNextId, getTraceId, getTraceObjectName, isDebugEnabled, isInfoEnabled, logAndConvert, quote, quoteArray, quoteBigDecimal, quoteBytes, quoteDate, quoteIntArray, quoteMap, quoteTime, quoteTimestamp, setTrace, unsupported
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.sql.Statement
cancel, clearWarnings, closeOnCompletion, enquoteIdentifier, enquoteLiteral, enquoteNCharLiteral, execute, execute, execute, execute, executeLargeUpdate, executeLargeUpdate, executeLargeUpdate, executeLargeUpdate, executeUpdate, executeUpdate, executeUpdate, executeUpdate, getConnection, getFetchDirection, getFetchSize, getLargeMaxRows, getLargeUpdateCount, getMaxFieldSize, getMaxRows, getMoreResults, getMoreResults, getQueryTimeout, getResultSet, getResultSetConcurrency, getResultSetHoldability, getResultSetType, getUpdateCount, getWarnings, isClosed, isCloseOnCompletion, isPoolable, isSimpleIdentifier, setCursorName, setEscapeProcessing, setFetchDirection, setFetchSize, setLargeMaxRows, setMaxFieldSize, setMaxRows, setPoolable, setQueryTimeout
-
-
-
-
Field Detail
-
command
protected CommandInterface command
-
batchParameters
private java.util.ArrayList<Value[]> batchParameters
-
batchIdentities
private MergedResult batchIdentities
-
cachedColumnLabelMap
private java.util.HashMap<java.lang.String,java.lang.Integer> cachedColumnLabelMap
-
generatedKeysRequest
private final java.lang.Object generatedKeysRequest
-
-
Constructor Detail
-
JdbcPreparedStatement
JdbcPreparedStatement(JdbcConnection conn, java.lang.String sql, int id, int resultSetType, int resultSetConcurrency, java.lang.Object generatedKeysRequest)
-
-
Method Detail
-
setCachedColumnLabelMap
void setCachedColumnLabelMap(java.util.HashMap<java.lang.String,java.lang.Integer> cachedColumnLabelMap)
Cache the column labels (looking up the column index can sometimes show up on the performance profile).- Parameters:
cachedColumnLabelMap- the column map
-
executeQuery
public java.sql.ResultSet executeQuery() throws java.sql.SQLExceptionExecutes a query (select statement) and returns the result set. If another result set exists for this statement, this will be closed (even if this statement fails).- Specified by:
executeQueryin interfacejava.sql.PreparedStatement- Returns:
- the result set
- Throws:
java.sql.SQLException- if this object is closed or invalid
-
executeUpdate
public int executeUpdate() throws java.sql.SQLExceptionExecutes a statement (insert, update, delete, create, drop) and returns the update count. If another result set exists for this statement, this will be closed (even if this statement fails). If auto commit is on, this statement will be committed. If the statement is a DDL statement (create, drop, alter) and does not throw an exception, the current transaction (if any) is committed after executing the statement.- Specified by:
executeUpdatein interfacejava.sql.PreparedStatement- Returns:
- the update count (number of affected rows by a DML statement or
other statement able to return number of rows, or 0 if no rows
were affected or the statement returns nothing, or
Statement.SUCCESS_NO_INFOif number of rows is too large forintdata type) - Throws:
java.sql.SQLException- if this object is closed or invalid- See Also:
executeLargeUpdate()
-
executeLargeUpdate
public long executeLargeUpdate() throws java.sql.SQLExceptionExecutes a statement (insert, update, delete, create, drop) and returns the update count. If another result set exists for this statement, this will be closed (even if this statement fails). If auto commit is on, this statement will be committed. If the statement is a DDL statement (create, drop, alter) and does not throw an exception, the current transaction (if any) is committed after executing the statement.- Specified by:
executeLargeUpdatein interfacejava.sql.PreparedStatement- Returns:
- the update count (number of affected rows by a DML statement or other statement able to return number of rows, or 0 if no rows were affected or the statement returns nothing)
- Throws:
java.sql.SQLException- if this object is closed or invalid
-
executeUpdateInternal
private long executeUpdateInternal()
-
execute
public boolean execute() throws java.sql.SQLExceptionExecutes an arbitrary statement. If another result set exists for this statement, this will be closed (even if this statement fails). If auto commit is on, and the statement is not a select, this statement will be committed.- Specified by:
executein interfacejava.sql.PreparedStatement- Returns:
- true if a result set is available, false if not
- Throws:
java.sql.SQLException- if this object is closed or invalid
-
clearParameters
public void clearParameters() throws java.sql.SQLExceptionClears all parameters.- Specified by:
clearParametersin interfacejava.sql.PreparedStatement- Throws:
java.sql.SQLException- if this object is closed or invalid
-
executeQuery
public java.sql.ResultSet executeQuery(java.lang.String sql) throws java.sql.SQLExceptionCalling this method is not legal on a PreparedStatement.- Specified by:
executeQueryin interfacejava.sql.Statement- Overrides:
executeQueryin classJdbcStatement- Parameters:
sql- ignored- Returns:
- the result set
- Throws:
java.sql.SQLException- Unsupported Feature
-
addBatch
public void addBatch(java.lang.String sql) throws java.sql.SQLExceptionCalling this method is not legal on a PreparedStatement.- Specified by:
addBatchin interfacejava.sql.Statement- Overrides:
addBatchin classJdbcStatement- Parameters:
sql- ignored- Throws:
java.sql.SQLException- Unsupported Feature
-
setNull
public void setNull(int parameterIndex, int sqlType) throws java.sql.SQLExceptionSets a parameter to null.- Specified by:
setNullin interfacejava.sql.PreparedStatement- Parameters:
parameterIndex- the parameter index (1, 2, ...)sqlType- the data type (Types.x)- Throws:
java.sql.SQLException- if this object is closed
-
setInt
public void setInt(int parameterIndex, int x) throws java.sql.SQLExceptionSets the value of a parameter.- Specified by:
setIntin interfacejava.sql.PreparedStatement- Parameters:
parameterIndex- the parameter index (1, 2, ...)x- the value- Throws:
java.sql.SQLException- if this object is closed
-
setString
public void setString(int parameterIndex, java.lang.String x) throws java.sql.SQLExceptionSets the value of a parameter.- Specified by:
setStringin interfacejava.sql.PreparedStatement- Parameters:
parameterIndex- the parameter index (1, 2, ...)x- the value- Throws:
java.sql.SQLException- if this object is closed
-
setBigDecimal
public void setBigDecimal(int parameterIndex, java.math.BigDecimal x) throws java.sql.SQLExceptionSets the value of a parameter.- Specified by:
setBigDecimalin interfacejava.sql.PreparedStatement- Parameters:
parameterIndex- the parameter index (1, 2, ...)x- the value- Throws:
java.sql.SQLException- if this object is closed
-
setDate
public void setDate(int parameterIndex, java.sql.Date x) throws java.sql.SQLExceptionSets the value of a parameter.Usage of this method is discouraged. Use
setObject(parameterIndex, value)withLocalDateparameter instead.- Specified by:
setDatein interfacejava.sql.PreparedStatement- Parameters:
parameterIndex- the parameter index (1, 2, ...)x- the value- Throws:
java.sql.SQLException- if this object is closed- See Also:
setObject(int, Object)
-
setTime
public void setTime(int parameterIndex, java.sql.Time x) throws java.sql.SQLExceptionSets the value of a parameter.Usage of this method is discouraged. Use
setObject(parameterIndex, value)withLocalTimeparameter instead.- Specified by:
setTimein interfacejava.sql.PreparedStatement- Parameters:
parameterIndex- the parameter index (1, 2, ...)x- the value- Throws:
java.sql.SQLException- if this object is closed- See Also:
setObject(int, Object)
-
setTimestamp
public void setTimestamp(int parameterIndex, java.sql.Timestamp x) throws java.sql.SQLExceptionSets the value of a parameter.Usage of this method is discouraged. Use
setObject(parameterIndex, value)withLocalDateTimeparameter instead.- Specified by:
setTimestampin interfacejava.sql.PreparedStatement- Parameters:
parameterIndex- the parameter index (1, 2, ...)x- the value- Throws:
java.sql.SQLException- if this object is closed- See Also:
setObject(int, Object)
-
setObject
public void setObject(int parameterIndex, java.lang.Object x) throws java.sql.SQLExceptionSets the value of a parameter. Objects of unknown classes are serialized (on the client side).- Specified by:
setObjectin interfacejava.sql.PreparedStatement- Parameters:
parameterIndex- the parameter index (1, 2, ...)x- the value- Throws:
java.sql.SQLException- if this object is closed
-
setObject
public void setObject(int parameterIndex, java.lang.Object x, int targetSqlType) throws java.sql.SQLExceptionSets the value of a parameter. The object is converted, if required, to the specified data type before sending to the database. Objects of unknown classes are serialized (on the client side).- Specified by:
setObjectin interfacejava.sql.PreparedStatement- Parameters:
parameterIndex- the parameter index (1, 2, ...)x- the value, null is allowedtargetSqlType- the type as defined in java.sql.Types- Throws:
java.sql.SQLException- if this object is closed
-
setObject
public void setObject(int parameterIndex, java.lang.Object x, int targetSqlType, int scale) throws java.sql.SQLExceptionSets the value of a parameter. The object is converted, if required, to the specified data type before sending to the database. Objects of unknown classes are serialized (on the client side).- Specified by:
setObjectin interfacejava.sql.PreparedStatement- Parameters:
parameterIndex- the parameter index (1, 2, ...)x- the value, null is allowedtargetSqlType- the type as defined in java.sql.Typesscale- is ignored- Throws:
java.sql.SQLException- if this object is closed
-
setObject
public void setObject(int parameterIndex, java.lang.Object x, java.sql.SQLType targetSqlType) throws java.sql.SQLExceptionSets the value of a parameter. The object is converted, if required, to the specified data type before sending to the database. Objects of unknown classes are serialized (on the client side).- Specified by:
setObjectin interfacejava.sql.PreparedStatement- Parameters:
parameterIndex- the parameter index (1, 2, ...)x- the value, null is allowedtargetSqlType- the SQL type- Throws:
java.sql.SQLException- if this object is closed
-
setObject
public void setObject(int parameterIndex, java.lang.Object x, java.sql.SQLType targetSqlType, int scaleOrLength) throws java.sql.SQLExceptionSets the value of a parameter. The object is converted, if required, to the specified data type before sending to the database. Objects of unknown classes are serialized (on the client side).- Specified by:
setObjectin interfacejava.sql.PreparedStatement- Parameters:
parameterIndex- the parameter index (1, 2, ...)x- the value, null is allowedtargetSqlType- the SQL typescaleOrLength- is ignored- Throws:
java.sql.SQLException- if this object is closed
-
setObjectWithType
private void setObjectWithType(int parameterIndex, java.lang.Object x, int type)
-
setBoolean
public void setBoolean(int parameterIndex, boolean x) throws java.sql.SQLExceptionSets the value of a parameter.- Specified by:
setBooleanin interfacejava.sql.PreparedStatement- Parameters:
parameterIndex- the parameter index (1, 2, ...)x- the value- Throws:
java.sql.SQLException- if this object is closed
-
setByte
public void setByte(int parameterIndex, byte x) throws java.sql.SQLExceptionSets the value of a parameter.- Specified by:
setBytein interfacejava.sql.PreparedStatement- Parameters:
parameterIndex- the parameter index (1, 2, ...)x- the value- Throws:
java.sql.SQLException- if this object is closed
-
setShort
public void setShort(int parameterIndex, short x) throws java.sql.SQLExceptionSets the value of a parameter.- Specified by:
setShortin interfacejava.sql.PreparedStatement- Parameters:
parameterIndex- the parameter index (1, 2, ...)x- the value- Throws:
java.sql.SQLException- if this object is closed
-
setLong
public void setLong(int parameterIndex, long x) throws java.sql.SQLExceptionSets the value of a parameter.- Specified by:
setLongin interfacejava.sql.PreparedStatement- Parameters:
parameterIndex- the parameter index (1, 2, ...)x- the value- Throws:
java.sql.SQLException- if this object is closed
-
setFloat
public void setFloat(int parameterIndex, float x) throws java.sql.SQLExceptionSets the value of a parameter.- Specified by:
setFloatin interfacejava.sql.PreparedStatement- Parameters:
parameterIndex- the parameter index (1, 2, ...)x- the value- Throws:
java.sql.SQLException- if this object is closed
-
setDouble
public void setDouble(int parameterIndex, double x) throws java.sql.SQLExceptionSets the value of a parameter.- Specified by:
setDoublein interfacejava.sql.PreparedStatement- Parameters:
parameterIndex- the parameter index (1, 2, ...)x- the value- Throws:
java.sql.SQLException- if this object is closed
-
setRef
public void setRef(int parameterIndex, java.sql.Ref x) throws java.sql.SQLException[Not supported] Sets the value of a column as a reference.- Specified by:
setRefin interfacejava.sql.PreparedStatement- Throws:
java.sql.SQLException
-
setDate
public void setDate(int parameterIndex, java.sql.Date x, java.util.Calendar calendar) throws java.sql.SQLExceptionSets the date using a specified time zone. The value will be converted to the local time zone.Usage of this method is discouraged. Use
setObject(parameterIndex, value)withLocalDateparameter instead.- Specified by:
setDatein interfacejava.sql.PreparedStatement- Parameters:
parameterIndex- the parameter index (1, 2, ...)x- the valuecalendar- the calendar- Throws:
java.sql.SQLException- if this object is closed- See Also:
setObject(int, Object)
-
setTime
public void setTime(int parameterIndex, java.sql.Time x, java.util.Calendar calendar) throws java.sql.SQLExceptionSets the time using a specified time zone. The value will be converted to the local time zone.Usage of this method is discouraged. Use
setObject(parameterIndex, value)withLocalTimeparameter instead.- Specified by:
setTimein interfacejava.sql.PreparedStatement- Parameters:
parameterIndex- the parameter index (1, 2, ...)x- the valuecalendar- the calendar- Throws:
java.sql.SQLException- if this object is closed- See Also:
setObject(int, Object)
-
setTimestamp
public void setTimestamp(int parameterIndex, java.sql.Timestamp x, java.util.Calendar calendar) throws java.sql.SQLExceptionSets the timestamp using a specified time zone. The value will be converted to the local time zone.Usage of this method is discouraged. Use
setObject(parameterIndex, value)withLocalDateTimeparameter instead.- Specified by:
setTimestampin interfacejava.sql.PreparedStatement- Parameters:
parameterIndex- the parameter index (1, 2, ...)x- the valuecalendar- the calendar- Throws:
java.sql.SQLException- if this object is closed- See Also:
setObject(int, Object)
-
setUnicodeStream
@Deprecated public void setUnicodeStream(int parameterIndex, java.io.InputStream x, int length) throws java.sql.SQLExceptionDeprecated.since JDBC 2.0, use setCharacterStream[Not supported] This feature is deprecated and not supported.- Specified by:
setUnicodeStreamin interfacejava.sql.PreparedStatement- Throws:
java.sql.SQLException
-
setNull
public void setNull(int parameterIndex, int sqlType, java.lang.String typeName) throws java.sql.SQLExceptionSets a parameter to null.- Specified by:
setNullin interfacejava.sql.PreparedStatement- Parameters:
parameterIndex- the parameter index (1, 2, ...)sqlType- the data type (Types.x)typeName- this parameter is ignored- Throws:
java.sql.SQLException- if this object is closed
-
setBlob
public void setBlob(int parameterIndex, java.sql.Blob x) throws java.sql.SQLExceptionSets the value of a parameter as a Blob.- Specified by:
setBlobin interfacejava.sql.PreparedStatement- Parameters:
parameterIndex- the parameter index (1, 2, ...)x- the value- Throws:
java.sql.SQLException- if this object is closed
-
setBlob
public void setBlob(int parameterIndex, java.io.InputStream x) throws java.sql.SQLExceptionSets the value of a parameter as a Blob. This method does not close the stream. The stream may be closed after executing the statement.- Specified by:
setBlobin interfacejava.sql.PreparedStatement- Parameters:
parameterIndex- the parameter index (1, 2, ...)x- the value- Throws:
java.sql.SQLException- if this object is closed
-
setClob
public void setClob(int parameterIndex, java.sql.Clob x) throws java.sql.SQLExceptionSets the value of a parameter as a Clob.- Specified by:
setClobin interfacejava.sql.PreparedStatement- Parameters:
parameterIndex- the parameter index (1, 2, ...)x- the value- Throws:
java.sql.SQLException- if this object is closed
-
setClob
public void setClob(int parameterIndex, java.io.Reader x) throws java.sql.SQLExceptionSets the value of a parameter as a Clob. This method does not close the reader. The reader may be closed after executing the statement.- Specified by:
setClobin interfacejava.sql.PreparedStatement- Parameters:
parameterIndex- the parameter index (1, 2, ...)x- the value- Throws:
java.sql.SQLException- if this object is closed
-
setArray
public void setArray(int parameterIndex, java.sql.Array x) throws java.sql.SQLExceptionSets the value of a parameter as an Array.- Specified by:
setArrayin interfacejava.sql.PreparedStatement- Parameters:
parameterIndex- the parameter index (1, 2, ...)x- the value- Throws:
java.sql.SQLException- if this object is closed
-
setBytes
public void setBytes(int parameterIndex, byte[] x) throws java.sql.SQLExceptionSets the value of a parameter as a byte array.- Specified by:
setBytesin interfacejava.sql.PreparedStatement- Parameters:
parameterIndex- the parameter index (1, 2, ...)x- the value- Throws:
java.sql.SQLException- if this object is closed
-
setBinaryStream
public void setBinaryStream(int parameterIndex, java.io.InputStream x, long length) throws java.sql.SQLExceptionSets the value of a parameter as an input stream. This method does not close the stream. The stream may be closed after executing the statement.- Specified by:
setBinaryStreamin interfacejava.sql.PreparedStatement- Parameters:
parameterIndex- the parameter index (1, 2, ...)x- the valuelength- the maximum number of bytes- Throws:
java.sql.SQLException- if this object is closed
-
setBinaryStream
public void setBinaryStream(int parameterIndex, java.io.InputStream x, int length) throws java.sql.SQLExceptionSets the value of a parameter as an input stream. This method does not close the stream. The stream may be closed after executing the statement.- Specified by:
setBinaryStreamin interfacejava.sql.PreparedStatement- Parameters:
parameterIndex- the parameter index (1, 2, ...)x- the valuelength- the maximum number of bytes- Throws:
java.sql.SQLException- if this object is closed
-
setBinaryStream
public void setBinaryStream(int parameterIndex, java.io.InputStream x) throws java.sql.SQLExceptionSets the value of a parameter as an input stream. This method does not close the stream. The stream may be closed after executing the statement.- Specified by:
setBinaryStreamin interfacejava.sql.PreparedStatement- Parameters:
parameterIndex- the parameter index (1, 2, ...)x- the value- Throws:
java.sql.SQLException- if this object is closed
-
setAsciiStream
public void setAsciiStream(int parameterIndex, java.io.InputStream x, int length) throws java.sql.SQLExceptionSets the value of a parameter as an ASCII stream. This method does not close the stream. The stream may be closed after executing the statement.- Specified by:
setAsciiStreamin interfacejava.sql.PreparedStatement- Parameters:
parameterIndex- the parameter index (1, 2, ...)x- the valuelength- the maximum number of bytes- Throws:
java.sql.SQLException- if this object is closed
-
setAsciiStream
public void setAsciiStream(int parameterIndex, java.io.InputStream x, long length) throws java.sql.SQLExceptionSets the value of a parameter as an ASCII stream. This method does not close the stream. The stream may be closed after executing the statement.- Specified by:
setAsciiStreamin interfacejava.sql.PreparedStatement- Parameters:
parameterIndex- the parameter index (1, 2, ...)x- the valuelength- the maximum number of bytes- Throws:
java.sql.SQLException- if this object is closed
-
setAsciiStream
public void setAsciiStream(int parameterIndex, java.io.InputStream x) throws java.sql.SQLExceptionSets the value of a parameter as an ASCII stream. This method does not close the stream. The stream may be closed after executing the statement.- Specified by:
setAsciiStreamin interfacejava.sql.PreparedStatement- Parameters:
parameterIndex- the parameter index (1, 2, ...)x- the value- Throws:
java.sql.SQLException- if this object is closed
-
setCharacterStream
public void setCharacterStream(int parameterIndex, java.io.Reader x, int length) throws java.sql.SQLExceptionSets the value of a parameter as a character stream. This method does not close the reader. The reader may be closed after executing the statement.- Specified by:
setCharacterStreamin interfacejava.sql.PreparedStatement- Parameters:
parameterIndex- the parameter index (1, 2, ...)x- the valuelength- the maximum number of characters- Throws:
java.sql.SQLException- if this object is closed
-
setCharacterStream
public void setCharacterStream(int parameterIndex, java.io.Reader x) throws java.sql.SQLExceptionSets the value of a parameter as a character stream. This method does not close the reader. The reader may be closed after executing the statement.- Specified by:
setCharacterStreamin interfacejava.sql.PreparedStatement- Parameters:
parameterIndex- the parameter index (1, 2, ...)x- the value- Throws:
java.sql.SQLException- if this object is closed
-
setCharacterStream
public void setCharacterStream(int parameterIndex, java.io.Reader x, long length) throws java.sql.SQLExceptionSets the value of a parameter as a character stream. This method does not close the reader. The reader may be closed after executing the statement.- Specified by:
setCharacterStreamin interfacejava.sql.PreparedStatement- Parameters:
parameterIndex- the parameter index (1, 2, ...)x- the valuelength- the maximum number of characters- Throws:
java.sql.SQLException- if this object is closed
-
setURL
public void setURL(int parameterIndex, java.net.URL x) throws java.sql.SQLException[Not supported]- Specified by:
setURLin interfacejava.sql.PreparedStatement- Throws:
java.sql.SQLException
-
getMetaData
public java.sql.ResultSetMetaData getMetaData() throws java.sql.SQLExceptionGets the result set metadata of the query returned when the statement is executed. If this is not a query, this method returns null.- Specified by:
getMetaDatain interfacejava.sql.PreparedStatement- Returns:
- the meta data or null if this is not a query
- Throws:
java.sql.SQLException- if this object is closed
-
clearBatch
public void clearBatch() throws java.sql.SQLExceptionClears the batch.- Specified by:
clearBatchin interfacejava.sql.Statement- Overrides:
clearBatchin classJdbcStatement- Throws:
java.sql.SQLException
-
close
public void close() throws java.sql.SQLExceptionCloses this statement. All result sets that where created by this statement become invalid after calling this method.- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.sql.Statement- Overrides:
closein classJdbcStatement- Throws:
java.sql.SQLException
-
executeBatch
public int[] executeBatch() throws java.sql.SQLExceptionExecutes the batch. If one of the batched statements fails, this database will continue.- Specified by:
executeBatchin interfacejava.sql.Statement- Overrides:
executeBatchin classJdbcStatement- Returns:
- the array of update counts
- Throws:
java.sql.SQLException- See Also:
executeLargeBatch()
-
executeLargeBatch
public long[] executeLargeBatch() throws java.sql.SQLExceptionExecutes the batch. If one of the batched statements fails, this database will continue.- Specified by:
executeLargeBatchin interfacejava.sql.Statement- Overrides:
executeLargeBatchin classJdbcStatement- Returns:
- the array of update counts
- Throws:
java.sql.SQLException
-
executeBatchElement
private long executeBatchElement(Value[] set, java.sql.SQLException exception)
-
getGeneratedKeys
public java.sql.ResultSet getGeneratedKeys() throws java.sql.SQLExceptionDescription copied from class:JdbcStatementReturn a result set with generated keys from the latest executed command or an empty result set if keys were not generated or were not requested withStatement.RETURN_GENERATED_KEYS, column indexes, or column names.Generated keys are only returned from from
INSERT,UPDATE,MERGE INTO, andMERGE INTO ... USINGcommands.If SQL command inserts or updates multiple rows with generated keys each such inserted or updated row is returned. Batch methods are also supported.
When
Statement.RETURN_GENERATED_KEYSis used H2 chooses columns to return automatically. The following columns are chosen:- Columns with sequences including
IDENTITYcolumns and columns withAUTO_INCREMENT. - Columns with other default values that are not evaluated into
constant expressions (like
DEFAULT RANDOM_UUID()). - Columns that are included into the PRIMARY KEY constraint.
Exact required columns for the returning result set may be specified on execution of command with names or indexes of columns.
- Specified by:
getGeneratedKeysin interfacejava.sql.Statement- Overrides:
getGeneratedKeysin classJdbcStatement- Returns:
- the possibly empty result set with generated keys
- Throws:
java.sql.SQLException- if this object is closed
- Columns with sequences including
-
addBatch
public void addBatch() throws java.sql.SQLExceptionAdds the current settings to the batch.- Specified by:
addBatchin interfacejava.sql.PreparedStatement- Throws:
java.sql.SQLException
-
getParameterMetaData
public java.sql.ParameterMetaData getParameterMetaData() throws java.sql.SQLExceptionGet the parameter meta data of this prepared statement.- Specified by:
getParameterMetaDatain interfacejava.sql.PreparedStatement- Returns:
- the meta data
- Throws:
java.sql.SQLException
-
setParameter
private void setParameter(int parameterIndex, Value value)
-
setRowId
public void setRowId(int parameterIndex, java.sql.RowId x) throws java.sql.SQLException[Not supported] Sets the value of a parameter as a row id.- Specified by:
setRowIdin interfacejava.sql.PreparedStatement- Throws:
java.sql.SQLException
-
setNString
public void setNString(int parameterIndex, java.lang.String x) throws java.sql.SQLExceptionSets the value of a parameter.- Specified by:
setNStringin interfacejava.sql.PreparedStatement- Parameters:
parameterIndex- the parameter index (1, 2, ...)x- the value- Throws:
java.sql.SQLException- if this object is closed
-
setNCharacterStream
public void setNCharacterStream(int parameterIndex, java.io.Reader x, long length) throws java.sql.SQLExceptionSets the value of a parameter as a character stream. This method does not close the reader. The reader may be closed after executing the statement.- Specified by:
setNCharacterStreamin interfacejava.sql.PreparedStatement- Parameters:
parameterIndex- the parameter index (1, 2, ...)x- the valuelength- the maximum number of characters- Throws:
java.sql.SQLException- if this object is closed
-
setNCharacterStream
public void setNCharacterStream(int parameterIndex, java.io.Reader x) throws java.sql.SQLExceptionSets the value of a parameter as a character stream. This method does not close the reader. The reader may be closed after executing the statement.- Specified by:
setNCharacterStreamin interfacejava.sql.PreparedStatement- Parameters:
parameterIndex- the parameter index (1, 2, ...)x- the value- Throws:
java.sql.SQLException- if this object is closed
-
setNClob
public void setNClob(int parameterIndex, java.sql.NClob x) throws java.sql.SQLExceptionSets the value of a parameter as a Clob.- Specified by:
setNClobin interfacejava.sql.PreparedStatement- Parameters:
parameterIndex- the parameter index (1, 2, ...)x- the value- Throws:
java.sql.SQLException- if this object is closed
-
setNClob
public void setNClob(int parameterIndex, java.io.Reader x) throws java.sql.SQLExceptionSets the value of a parameter as a Clob. This method does not close the reader. The reader may be closed after executing the statement.- Specified by:
setNClobin interfacejava.sql.PreparedStatement- Parameters:
parameterIndex- the parameter index (1, 2, ...)x- the value- Throws:
java.sql.SQLException- if this object is closed
-
setClob
public void setClob(int parameterIndex, java.io.Reader x, long length) throws java.sql.SQLExceptionSets the value of a parameter as a Clob. This method does not close the reader. The reader may be closed after executing the statement.- Specified by:
setClobin interfacejava.sql.PreparedStatement- Parameters:
parameterIndex- the parameter index (1, 2, ...)x- the valuelength- the maximum number of characters- Throws:
java.sql.SQLException- if this object is closed
-
setBlob
public void setBlob(int parameterIndex, java.io.InputStream x, long length) throws java.sql.SQLExceptionSets the value of a parameter as a Blob. This method does not close the stream. The stream may be closed after executing the statement.- Specified by:
setBlobin interfacejava.sql.PreparedStatement- Parameters:
parameterIndex- the parameter index (1, 2, ...)x- the valuelength- the maximum number of bytes- Throws:
java.sql.SQLException- if this object is closed
-
setNClob
public void setNClob(int parameterIndex, java.io.Reader x, long length) throws java.sql.SQLExceptionSets the value of a parameter as a Clob. This method does not close the reader. The reader may be closed after executing the statement.- Specified by:
setNClobin interfacejava.sql.PreparedStatement- Parameters:
parameterIndex- the parameter index (1, 2, ...)x- the valuelength- the maximum number of characters- Throws:
java.sql.SQLException- if this object is closed
-
setSQLXML
public void setSQLXML(int parameterIndex, java.sql.SQLXML x) throws java.sql.SQLExceptionSets the value of a parameter as a SQLXML.- Specified by:
setSQLXMLin interfacejava.sql.PreparedStatement- Parameters:
parameterIndex- the parameter index (1, 2, ...)x- the value- Throws:
java.sql.SQLException- if this object is closed
-
toString
public java.lang.String toString()
INTERNAL- Overrides:
toStringin classJdbcStatement
-
-