org.h2.jdbc

## 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, JdbcPreparedStatementBackwardsCompat, JdbcStatementBackwardsCompat

Direct Known Subclasses:
  JdbcCallableStatement

    public class JdbcPreparedStatement
    extends JdbcStatement
    implements java.sql.PreparedStatement, JdbcPreparedStatementBackwardsCompat

Represents a prepared statement.

### Field Summary

Fields
`protected CommandInterface` `command`

### Fields inherited from class org.h2.jdbc.JdbcStatement

`closedByResultSet, 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`

### 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`

### Method Summary

Methods
`void` `addBatch()` Adds the current settings to the batch.
`void` `addBatch(java.lang.String sql)` Calling this method is not legal on a PreparedStatement.
`protected boolean` `checkClosed(boolean write)` INTERNAL.
`void` `clearBatch()` Clears the batch.
`void` `clearParameters()` Clears all parameters.
`void` `close()` Closes this statement.
`boolean` `execute()` Executes an arbitrary statement.
`boolean` `execute(java.lang.String sql)` Calling this method is not legal on a PreparedStatement.
`boolean` `execute(java.lang.String sql, int autoGeneratedKeys)` Calling this method is not legal on a PreparedStatement.
`boolean` `execute(java.lang.String sql, int[] columnIndexes)` Calling this method is not legal on a PreparedStatement.
`boolean` `execute(java.lang.String sql, java.lang.String[] columnNames)` Calling this method is not legal on a PreparedStatement.
`int[]` `executeBatch()` Executes the batch.
`long` `executeLargeUpdate()` Executes a statement (insert, update, delete, create, drop) and returns the update count.
`long` `executeLargeUpdate(java.lang.String sql)` Calling this method is not legal on a PreparedStatement.
`long` `executeLargeUpdate(java.lang.String sql, int autoGeneratedKeys)` Calling this method is not legal on a PreparedStatement.
`long` `executeLargeUpdate(java.lang.String sql, int[] columnIndexes)` Calling this method is not legal on a PreparedStatement.
`long` `executeLargeUpdate(java.lang.String sql, java.lang.String[] columnNames)` Calling this method is not legal on a PreparedStatement.
`java.sql.ResultSet` `executeQuery()` Executes a query (select statement) and returns the result set.
`java.sql.ResultSet` `executeQuery(java.lang.String sql)` Calling this method is not legal on a PreparedStatement.
`int` `executeUpdate()` Executes a statement (insert, update, delete, create, drop) and returns the update count.
`int` `executeUpdate(java.lang.String sql)` Calling this method is not legal on a PreparedStatement.
`int` `executeUpdate(java.lang.String sql, int autoGeneratedKeys)` Calling this method is not legal on a PreparedStatement.
`int` `executeUpdate(java.lang.String sql, int[] columnIndexes)` Calling this method is not legal on a PreparedStatement.
`int` `executeUpdate(java.lang.String sql, java.lang.String[] columnNames)` Calling this method is not legal on a PreparedStatement.
`java.sql.ResultSet` `getGeneratedKeys()` 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 with `Statement.RETURN_GENERATED_KEYS`, column indexes, or column names.
`java.sql.ResultSetMetaData` `getMetaData()` Gets the result set metadata of the query returned when the statement is executed.
`java.sql.ParameterMetaData` `getParameterMetaData()` Get the parameter meta data of this prepared statement.
`void` `setArray(int parameterIndex, java.sql.Array x)` Sets the value of a parameter as an Array.
`void` `setAsciiStream(int parameterIndex, java.io.InputStream x)` Sets the value of a parameter as an ASCII stream.
`void` `setAsciiStream(int parameterIndex, java.io.InputStream x, int length)` Sets the value of a parameter as an ASCII stream.
`void` `setAsciiStream(int parameterIndex, java.io.InputStream x, long length)` Sets the value of a parameter as an ASCII stream.
`void` `setBigDecimal(int parameterIndex, java.math.BigDecimal x)` Sets the value of a parameter.
`void` `setBinaryStream(int parameterIndex, java.io.InputStream x)` Sets the value of a parameter as an input stream.
`void` `setBinaryStream(int parameterIndex, java.io.InputStream x, int length)` Sets the value of a parameter as an input stream.
`void` `setBinaryStream(int parameterIndex, java.io.InputStream x, long length)` Sets the value of a parameter as an input stream.
`void` `setBlob(int parameterIndex, java.sql.Blob x)` Sets the value of a parameter as a Blob.
`void` `setBlob(int parameterIndex, java.io.InputStream x)` Sets the value of a parameter as a Blob.
`void` `setBlob(int parameterIndex, java.io.InputStream x, long length)` Sets the value of a parameter as a Blob.
`void` `setBoolean(int parameterIndex, boolean x)` Sets the value of a parameter.
`void` `setByte(int parameterIndex, byte x)` Sets the value of a parameter.
`void` `setBytes(int parameterIndex, byte[] x)` Sets the value of a parameter as a byte array.
`void` `setCharacterStream(int parameterIndex, java.io.Reader x)` Sets the value of a parameter as a character stream.
`void` `setCharacterStream(int parameterIndex, java.io.Reader x, int length)` Sets the value of a parameter as a character stream.
`void` `setCharacterStream(int parameterIndex, java.io.Reader x, long length)` Sets the value of a parameter as a character stream.
`void` `setClob(int parameterIndex, java.sql.Clob x)` Sets the value of a parameter as a Clob.
`void` `setClob(int parameterIndex, java.io.Reader x)` Sets the value of a parameter as a Clob.
`void` `setClob(int parameterIndex, java.io.Reader x, long length)` Sets the value of a parameter as a Clob.
`void` `setDate(int parameterIndex, java.sql.Date x)` Sets the value of a parameter.
`void` `setDate(int parameterIndex, java.sql.Date x, java.util.Calendar calendar)` Sets the date using a specified time zone.
`void` `setDouble(int parameterIndex, double x)` Sets the value of a parameter.
`void` `setFloat(int parameterIndex, float x)` Sets the value of a parameter.
`void` `setInt(int parameterIndex, int x)` Sets the value of a parameter.
`void` `setLong(int parameterIndex, long x)` Sets the value of a parameter.
`void` `setNCharacterStream(int parameterIndex, java.io.Reader x)` Sets the value of a parameter as a character stream.
`void` `setNCharacterStream(int parameterIndex, java.io.Reader x, long length)` Sets the value of a parameter as a character stream.
`void` `setNClob(int parameterIndex, java.sql.NClob x)` Sets the value of a parameter as a Clob.
`void` `setNClob(int parameterIndex, java.io.Reader x)` Sets the value of a parameter as a Clob.
`void` `setNClob(int parameterIndex, java.io.Reader x, long length)` Sets the value of a parameter as a Clob.
`void` `setNString(int parameterIndex, java.lang.String x)` Sets the value of a parameter.
`void` `setNull(int parameterIndex, int sqlType)` Sets a parameter to null.
`void` `setNull(int parameterIndex, int sqlType, java.lang.String typeName)` Sets a parameter to null.
`void` `setObject(int parameterIndex, java.lang.Object x)` Sets the value of a parameter.
`void` `setObject(int parameterIndex, java.lang.Object x, int targetSqlType)` Sets the value of a parameter.
`void` `setObject(int parameterIndex, java.lang.Object x, int targetSqlType, int scale)` Sets the value of a parameter.
`void` `setRef(int parameterIndex, java.sql.Ref x)` [Not supported] Sets the value of a column as a reference.
`void` `setRowId(int parameterIndex, java.sql.RowId x)` [Not supported] Sets the value of a parameter as a row id.
`void` `setShort(int parameterIndex, short x)` Sets the value of a parameter.
`void` `setSQLXML(int parameterIndex, java.sql.SQLXML x)` Sets the value of a parameter as a SQLXML.
`void` `setString(int parameterIndex, java.lang.String x)` Sets the value of a parameter.
`void` `setTime(int parameterIndex, java.sql.Time x)` Sets the value of a parameter.
`void` `setTime(int parameterIndex, java.sql.Time x, java.util.Calendar calendar)` Sets the time using a specified time zone.
`void` `setTimestamp(int parameterIndex, java.sql.Timestamp x)` Sets the value of a parameter.
`void` `setTimestamp(int parameterIndex, java.sql.Timestamp x, java.util.Calendar calendar)` Sets the timestamp using a specified time zone.
`void` `setUnicodeStream(int parameterIndex, java.io.InputStream x, int length)` Deprecated. since JDBC 2.0, use setCharacterStream
`void` `setURL(int parameterIndex, java.net.URL x)` [Not supported]
`java.lang.String` `toString()` INTERNAL

### Methods inherited from class org.h2.jdbc.JdbcStatement

`cancel, clearWarnings, closeOldResultSet, closeOnCompletion, enquoteIdentifier, executeLargeBatch, getConnection, getFetchDirection, getFetchSize, getLargeMaxRows, getLargeUpdateCount, getLastExecutedCommandType, getMaxFieldSize, getMaxRows, getMoreResults, getMoreResults, getQueryTimeout, getResultSet, getResultSetConcurrency, getResultSetHoldability, getResultSetType, getUpdateCount, getWarnings, isCancelled, isClosed, isCloseOnCompletion, isPoolable, isSimpleIdentifier, isWrapperFor, 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, getConnection, getFetchDirection, getFetchSize, getMaxFieldSize, getMaxRows, getMoreResults, getMoreResults, getQueryTimeout, getResultSet, getResultSetConcurrency, getResultSetHoldability, getResultSetType, getUpdateCount, getWarnings, isClosed, isCloseOnCompletion, isPoolable, setCursorName, setEscapeProcessing, setFetchDirection, setFetchSize, setMaxFieldSize, setMaxRows, setPoolable, setQueryTimeout`

### Methods inherited from interface java.sql.Wrapper

`isWrapperFor, unwrap`

### Field Detail

#### command

    protected CommandInterface command

### Method Detail

#### executeQuery

    public java.sql.ResultSet executeQuery()
                                    throws java.sql.SQLException

Executes 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:
  `executeQuery` in interface `java.sql.PreparedStatement`
Returns:
  the result set
Throws:
  `java.sql.SQLException` - if this object is closed or invalid

#### executeUpdate

    public int executeUpdate()
                      throws java.sql.SQLException

Executes 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:
  `executeUpdate` in interface `java.sql.PreparedStatement`
Returns:
  the update count (number of row affected by an insert, update or delete, or 0 if no rows or the statement was a create, drop, commit or rollback)
Throws:
  `java.sql.SQLException` - if this object is closed or invalid

#### executeLargeUpdate

    public long executeLargeUpdate()
                            throws java.sql.SQLException

Executes 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:
  `executeLargeUpdate` in interface `JdbcPreparedStatementBackwardsCompat`
Returns:
  the update count (number of row affected by an insert, update or delete, or 0 if no rows or the statement was a create, drop, commit or rollback)
Throws:
  `java.sql.SQLException` - if this object is closed or invalid

#### execute

    public boolean execute()
                    throws java.sql.SQLException

Executes 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:
  `execute` in interface `java.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.SQLException

Clears all parameters.

Specified by:
  `clearParameters` in interface `java.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.SQLException

Calling this method is not legal on a PreparedStatement.

Specified by:
  `executeQuery` in interface `java.sql.Statement`
Overrides:
  `executeQuery` in class `JdbcStatement`
Parameters:
  `sql` - ignored
Returns:
  the result set
Throws:
  `java.sql.SQLException` - Unsupported Feature

#### addBatch

    public void addBatch(java.lang.String sql)
                  throws java.sql.SQLException

Calling this method is not legal on a PreparedStatement.

Specified by:
  `addBatch` in interface `java.sql.Statement`
Overrides:
  `addBatch` in class `JdbcStatement`
Parameters:
  `sql` - ignored
Throws:
  `java.sql.SQLException` - Unsupported Feature

#### executeUpdate

    public int executeUpdate(java.lang.String sql)
                      throws java.sql.SQLException

Calling this method is not legal on a PreparedStatement.

Specified by:
  `executeUpdate` in interface `java.sql.Statement`
Overrides:
  `executeUpdate` in class `JdbcStatement`
Parameters:
  `sql` - ignored
Returns:
  the update count (number of row affected by an insert, update or delete, or 0 if no rows or the statement was a create, drop, commit or rollback)
Throws:
  `java.sql.SQLException` - Unsupported Feature

#### executeLargeUpdate

    public long executeLargeUpdate(java.lang.String sql)
                            throws java.sql.SQLException

Calling this method is not legal on a PreparedStatement.

Specified by:
  `executeLargeUpdate` in interface `JdbcStatementBackwardsCompat`
Overrides:
  `executeLargeUpdate` in class `JdbcStatement`
Parameters:
  `sql` - ignored
Returns:
  the update count (number of row affected by an insert, update or delete, or 0 if no rows or the statement was a create, drop, commit or rollback)
Throws:
  `java.sql.SQLException` - Unsupported Feature

#### execute

    public boolean execute(java.lang.String sql)
                    throws java.sql.SQLException

Calling this method is not legal on a PreparedStatement.

Specified by:
  `execute` in interface `java.sql.Statement`
Overrides:
  `execute` in class `JdbcStatement`
Parameters:
  `sql` - ignored
Returns:
  true if a result set is available, false if not
Throws:
  `java.sql.SQLException` - Unsupported Feature

#### setNull

    public void setNull(int parameterIndex,
               int sqlType)
                 throws java.sql.SQLException

Sets a parameter to null.

Specified by:
  `setNull` in interface `java.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.SQLException

Sets the value of a parameter.

Specified by:
  `setInt` in interface `java.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.SQLException

Sets the value of a parameter.

Specified by:
  `setString` in interface `java.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.SQLException

Sets the value of a parameter.

Specified by:
  `setBigDecimal` in interface `java.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.SQLException

Sets the value of a parameter.

Specified by:
  `setDate` in interface `java.sql.PreparedStatement`
Parameters:
  `parameterIndex` - the parameter index (1, 2, ...)
  `x` - the value
Throws:
  `java.sql.SQLException` - if this object is closed

#### setTime

    public void setTime(int parameterIndex,
               java.sql.Time x)
                 throws java.sql.SQLException

Sets the value of a parameter.

Specified by:
  `setTime` in interface `java.sql.PreparedStatement`
Parameters:
  `parameterIndex` - the parameter index (1, 2, ...)
  `x` - the value
Throws:
  `java.sql.SQLException` - if this object is closed

#### setTimestamp

    public void setTimestamp(int parameterIndex,
                    java.sql.Timestamp x)
                      throws java.sql.SQLException

Sets the value of a parameter.

Specified by:
  `setTimestamp` in interface `java.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)
                   throws java.sql.SQLException

Sets the value of a parameter. Objects of unknown classes are serialized (on the client side).

Specified by:
  `setObject` in interface `java.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.SQLException

Sets 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:
  `setObject` in interface `java.sql.PreparedStatement`
Parameters:
  `parameterIndex` - the parameter index (1, 2, ...)
  `x` - the value, null is allowed
  `targetSqlType` - 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.SQLException

Sets 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:
  `setObject` in interface `java.sql.PreparedStatement`
Parameters:
  `parameterIndex` - the parameter index (1, 2, ...)
  `x` - the value, null is allowed
  `targetSqlType` - the type as defined in java.sql.Types
  `scale` - is ignored
Throws:
  `java.sql.SQLException` - if this object is closed

#### setBoolean

    public void setBoolean(int parameterIndex,
                  boolean x)
                    throws java.sql.SQLException

Sets the value of a parameter.

Specified by:
  `setBoolean` in interface `java.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.SQLException

Sets the value of a parameter.

Specified by:
  `setByte` in interface `java.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.SQLException

Sets the value of a parameter.

Specified by:
  `setShort` in interface `java.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.SQLException

Sets the value of a parameter.

Specified by:
  `setLong` in interface `java.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.SQLException

Sets the value of a parameter.

Specified by:
  `setFloat` in interface `java.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.SQLException

Sets the value of a parameter.

Specified by:
  `setDouble` in interface `java.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:
  `setRef` in interface `java.sql.PreparedStatement`
Throws:
  `java.sql.SQLException`

#### setDate

    public void setDate(int parameterIndex,
               java.sql.Date x,
               java.util.Calendar calendar)
                 throws java.sql.SQLException

Sets the date using a specified time zone. The value will be converted to the local time zone.

Specified by:
  `setDate` in interface `java.sql.PreparedStatement`
Parameters:
  `parameterIndex` - the parameter index (1, 2, ...)
  `x` - the value
  `calendar` - the calendar
Throws:
  `java.sql.SQLException` - if this object is closed

#### setTime

    public void setTime(int parameterIndex,
               java.sql.Time x,
               java.util.Calendar calendar)
                 throws java.sql.SQLException

Sets the time using a specified time zone. The value will be converted to the local time zone.

Specified by:
  `setTime` in interface `java.sql.PreparedStatement`
Parameters:
  `parameterIndex` - the parameter index (1, 2, ...)
  `x` - the value
  `calendar` - the calendar
Throws:
  `java.sql.SQLException` - if this object is closed

#### setTimestamp

    public void setTimestamp(int parameterIndex,
                    java.sql.Timestamp x,
                    java.util.Calendar calendar)
                      throws java.sql.SQLException

Sets the timestamp using a specified time zone. The value will be converted to the local time zone.

Specified by:
  `setTimestamp` in interface `java.sql.PreparedStatement`
Parameters:
  `parameterIndex` - the parameter index (1, 2, ...)
  `x` - the value
  `calendar` - the calendar
Throws:
  `java.sql.SQLException` - if this object is closed

#### setUnicodeStream

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

Deprecated. since JDBC 2.0, use setCharacterStream
[Not supported] This feature is deprecated and not supported.

Specified by:
  `setUnicodeStream` in interface `java.sql.PreparedStatement`
Throws:
  `java.sql.SQLException`

#### setNull

    public void setNull(int parameterIndex,
               int sqlType,
               java.lang.String typeName)
                 throws java.sql.SQLException

Sets a parameter to null.

Specified by:
  `setNull` in interface `java.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.SQLException

Sets the value of a parameter as a Blob.

Specified by:
  `setBlob` in interface `java.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.SQLException

Sets 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:
  `setBlob` in interface `java.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.SQLException

Sets the value of a parameter as a Clob.

Specified by:
  `setClob` in interface `java.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.SQLException

Sets 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:
  `setClob` in interface `java.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.SQLException

Sets the value of a parameter as an Array.

Specified by:
  `setArray` in interface `java.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.SQLException

Sets the value of a parameter as a byte array.

Specified by:
  `setBytes` in interface `java.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.SQLException

Sets 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:
  `setBinaryStream` in interface `java.sql.PreparedStatement`
Parameters:
  `parameterIndex` - the parameter index (1, 2, ...)
  `x` - the value
  `length` - 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.SQLException

Sets 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:
  `setBinaryStream` in interface `java.sql.PreparedStatement`
Parameters:
  `parameterIndex` - the parameter index (1, 2, ...)
  `x` - the value
  `length` - 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.SQLException

Sets 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:
  `setBinaryStream` in interface `java.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.SQLException

Sets 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:
  `setAsciiStream` in interface `java.sql.PreparedStatement`
Parameters:
  `parameterIndex` - the parameter index (1, 2, ...)
  `x` - the value
  `length` - 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.SQLException

Sets 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:
  `setAsciiStream` in interface `java.sql.PreparedStatement`
Parameters:
  `parameterIndex` - the parameter index (1, 2, ...)
  `x` - the value
  `length` - 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.SQLException

Sets 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:
  `setAsciiStream` in interface `java.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.SQLException

Sets 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:
  `setCharacterStream` in interface `java.sql.PreparedStatement`
Parameters:
  `parameterIndex` - the parameter index (1, 2, ...)
  `x` - the value
  `length` - 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.SQLException

Sets 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:
  `setCharacterStream` in interface `java.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.SQLException

Sets 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:
  `setCharacterStream` in interface `java.sql.PreparedStatement`
Parameters:
  `parameterIndex` - the parameter index (1, 2, ...)
  `x` - the value
  `length` - 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:
  `setURL` in interface `java.sql.PreparedStatement`
Throws:
  `java.sql.SQLException`

#### getMetaData

    public java.sql.ResultSetMetaData getMetaData()
                                           throws java.sql.SQLException

Gets 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:
  `getMetaData` in interface `java.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.SQLException

Clears the batch.

Specified by:
  `clearBatch` in interface `java.sql.Statement`
Overrides:
  `clearBatch` in class `JdbcStatement`
Throws:
  `java.sql.SQLException`

#### close

    public void close()
               throws java.sql.SQLException

Closes this statement. All result sets that where created by this statement become invalid after calling this method.

Specified by:
  `close` in interface `java.lang.AutoCloseable`
Specified by:
  `close` in interface `java.sql.Statement`
Overrides:
  `close` in class `JdbcStatement`
Throws:
  `java.sql.SQLException`

#### executeBatch

    public int[] executeBatch()
                       throws java.sql.SQLException

Executes the batch. If one of the batched statements fails, this database will continue.

Specified by:
  `executeBatch` in interface `java.sql.Statement`
Overrides:
  `executeBatch` in class `JdbcStatement`
Returns:
  the array of update counts
Throws:
  `java.sql.SQLException`

#### getGeneratedKeys

    public java.sql.ResultSet getGeneratedKeys()
                                        throws java.sql.SQLException

Description copied from class: `JdbcStatement`
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 with `Statement.RETURN_GENERATED_KEYS`, column indexes, or column names.

Generated keys are only returned from inserted rows from `INSERT`, `MERGE INTO`, and `MERGE INTO ... USING` commands. Generated keys are not returned if exact values of generated columns were specified explicitly in SQL command. All columns with inserted generated values are included in the result if command was executed with `Statement.RETURN_GENERATED_KEYS` parameter.

If SQL command inserts multiple rows with generated keys each such inserted row is returned. Batch methods are also supported. When multiple rows are returned each row contains only generated values for this row. It's possible to insert several rows with generated values in different columns with some specific commands, in this special case the returned result set contains all used columns, but each row will contain only generated values, columns that were not generated for this row will contain `null` values.

H2 treats inserted value as generated in the following cases:

- Columns with sequences including `IDENTITY` columns and columns with `AUTO_INCREMENT` if value was generated automatically (not specified in command).
- Columns with other default values that are not evaluated into constant expressions (like `DEFAULT RANDOM_UUID()`) also only if default value was inserted.
- Columns that were set by triggers.
- Columns with values specified in command with invocation of some sequence (like `INSERT INTO ... VALUES (NEXT VALUE FOR ...)`).

Exact required columns for the returning result set may be specified on execution of command with names or indexes of columns to limit output or reorder columns in result set. Specifying of some column has no effect on treatment of inserted values as generated or not. If some value is not determined to be generated it will not be returned even on explicit request.

Specified by:
  `getGeneratedKeys` in interface `java.sql.Statement`
Overrides:
  `getGeneratedKeys` in class `JdbcStatement`
Returns:
  the possibly empty result set with generated keys
Throws:
  `java.sql.SQLException` - if this object is closed

#### addBatch

    public void addBatch()
                  throws java.sql.SQLException

Adds the current settings to the batch.

Specified by:
  `addBatch` in interface `java.sql.PreparedStatement`
Throws:
  `java.sql.SQLException`

#### executeUpdate

    public int executeUpdate(java.lang.String sql,
                    int autoGeneratedKeys)
                      throws java.sql.SQLException

Calling this method is not legal on a PreparedStatement.

Specified by:
  `executeUpdate` in interface `java.sql.Statement`
Overrides:
  `executeUpdate` in class `JdbcStatement`
Parameters:
  `sql` - ignored
  `autoGeneratedKeys` - ignored
Returns:
  the update count (number of row affected by an insert, update or delete, or 0 if no rows or the statement was a create, drop, commit or rollback)
Throws:
  `java.sql.SQLException` - Unsupported Feature

#### executeLargeUpdate

    public long executeLargeUpdate(java.lang.String sql,
                          int autoGeneratedKeys)
                            throws java.sql.SQLException

Calling this method is not legal on a PreparedStatement.

Specified by:
  `executeLargeUpdate` in interface `JdbcStatementBackwardsCompat`
Overrides:
  `executeLargeUpdate` in class `JdbcStatement`
Parameters:
  `sql` - ignored
  `autoGeneratedKeys` - ignored
Returns:
  the update count (number of row affected by an insert, update or delete, or 0 if no rows or the statement was a create, drop, commit or rollback)
Throws:
  `java.sql.SQLException` - Unsupported Feature

#### executeUpdate

    public int executeUpdate(java.lang.String sql,
                    int[] columnIndexes)
                      throws java.sql.SQLException

Calling this method is not legal on a PreparedStatement.

Specified by:
  `executeUpdate` in interface `java.sql.Statement`
Overrides:
  `executeUpdate` in class `JdbcStatement`
Parameters:
  `sql` - ignored
  `columnIndexes` - ignored
Returns:
  the update count (number of row affected by an insert, update or delete, or 0 if no rows or the statement was a create, drop, commit or rollback)
Throws:
  `java.sql.SQLException` - Unsupported Feature

#### executeLargeUpdate

    public long executeLargeUpdate(java.lang.String sql,
                          int[] columnIndexes)
                            throws java.sql.SQLException

Calling this method is not legal on a PreparedStatement.

Specified by:
  `executeLargeUpdate` in interface `JdbcStatementBackwardsCompat`
Overrides:
  `executeLargeUpdate` in class `JdbcStatement`
Parameters:
  `sql` - ignored
  `columnIndexes` - ignored
Returns:
  the update count (number of row affected by an insert, update or delete, or 0 if no rows or the statement was a create, drop, commit or rollback)
Throws:
  `java.sql.SQLException` - Unsupported Feature

#### executeUpdate

    public int executeUpdate(java.lang.String sql,
                    java.lang.String[] columnNames)
                      throws java.sql.SQLException

Calling this method is not legal on a PreparedStatement.

Specified by:
  `executeUpdate` in interface `java.sql.Statement`
Overrides:
  `executeUpdate` in class `JdbcStatement`
Parameters:
  `sql` - ignored
  `columnNames` - ignored
Returns:
  the update count (number of row affected by an insert, update or delete, or 0 if no rows or the statement was a create, drop, commit or rollback)
Throws:
  `java.sql.SQLException` - Unsupported Feature

#### executeLargeUpdate

    public long executeLargeUpdate(java.lang.String sql,
                          java.lang.String[] columnNames)
                            throws java.sql.SQLException

Calling this method is not legal on a PreparedStatement.

Specified by:
  `executeLargeUpdate` in interface `JdbcStatementBackwardsCompat`
Overrides:
  `executeLargeUpdate` in class `JdbcStatement`
Parameters:
  `sql` - ignored
  `columnNames` - ignored
Returns:
  the update count (number of row affected by an insert, update or delete, or 0 if no rows or the statement was a create, drop, commit or rollback)
Throws:
  `java.sql.SQLException` - Unsupported Feature

#### execute

    public boolean execute(java.lang.String sql,
                  int autoGeneratedKeys)
                    throws java.sql.SQLException

Calling this method is not legal on a PreparedStatement.

Specified by:
  `execute` in interface `java.sql.Statement`
Overrides:
  `execute` in class `JdbcStatement`
Parameters:
  `sql` - ignored
  `autoGeneratedKeys` - ignored
Returns:
  the update count (number of row affected by an insert, update or delete, or 0 if no rows or the statement was a create, drop, commit or rollback)
Throws:
  `java.sql.SQLException` - Unsupported Feature

#### execute

    public boolean execute(java.lang.String sql,
                  int[] columnIndexes)
                    throws java.sql.SQLException

Calling this method is not legal on a PreparedStatement.

Specified by:
  `execute` in interface `java.sql.Statement`
Overrides:
  `execute` in class `JdbcStatement`
Parameters:
  `sql` - ignored
  `columnIndexes` - ignored
Returns:
  the update count (number of row affected by an insert, update or delete, or 0 if no rows or the statement was a create, drop, commit or rollback)
Throws:
  `java.sql.SQLException` - Unsupported Feature

#### execute

    public boolean execute(java.lang.String sql,
                  java.lang.String[] columnNames)
                    throws java.sql.SQLException

Calling this method is not legal on a PreparedStatement.

Specified by:
  `execute` in interface `java.sql.Statement`
Overrides:
  `execute` in class `JdbcStatement`
Parameters:
  `sql` - ignored
  `columnNames` - ignored
Returns:
  the update count (number of row affected by an insert, update or delete, or 0 if no rows or the statement was a create, drop, commit or rollback)
Throws:
  `java.sql.SQLException` - Unsupported Feature

#### getParameterMetaData

    public java.sql.ParameterMetaData getParameterMetaData()
                                                    throws java.sql.SQLException

Get the parameter meta data of this prepared statement.

Specified by:
  `getParameterMetaData` in interface `java.sql.PreparedStatement`
Returns:
  the meta data
Throws:
  `java.sql.SQLException`

#### 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:
  `setRowId` in interface `java.sql.PreparedStatement`
Throws:
  `java.sql.SQLException`

#### setNString

    public void setNString(int parameterIndex,
                  java.lang.String x)
                    throws java.sql.SQLException

Sets the value of a parameter.

Specified by:
  `setNString` in interface `java.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.SQLException

Sets 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:
  `setNCharacterStream` in interface `java.sql.PreparedStatement`
Parameters:
  `parameterIndex` - the parameter index (1, 2, ...)
  `x` - the value
  `length` - 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.SQLException

Sets 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:
  `setNCharacterStream` in interface `java.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.SQLException

Sets the value of a parameter as a Clob.

Specified by:
  `setNClob` in interface `java.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.SQLException

Sets 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:
  `setNClob` in interface `java.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.SQLException

Sets 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:
  `setClob` in interface `java.sql.PreparedStatement`
Parameters:
  `parameterIndex` - the parameter index (1, 2, ...)
  `x` - the value
  `length` - 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.SQLException

Sets 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:
  `setBlob` in interface `java.sql.PreparedStatement`
Parameters:
  `parameterIndex` - the parameter index (1, 2, ...)
  `x` - the value
  `length` - 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.SQLException

Sets 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:
  `setNClob` in interface `java.sql.PreparedStatement`
Parameters:
  `parameterIndex` - the parameter index (1, 2, ...)
  `x` - the value
  `length` - 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.SQLException

Sets the value of a parameter as a SQLXML.

Specified by:
  `setSQLXML` in interface `java.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:
  `toString` in class `JdbcStatement`

#### checkClosed

    protected boolean checkClosed(boolean write)

Description copied from class: `JdbcStatement`
INTERNAL. Check if the statement is closed.

Overrides:
  `checkClosed` in class `JdbcStatement`
Parameters:
  `write` - if the next operation is possibly writing
Returns:
  true if a reconnect was required