Class JDBCPreparedStatement
- All Implemented Interfaces:
AutoCloseable,PreparedStatement,Statement,Wrapper
public class JDBCPreparedStatement extends JDBCStatement implements PreparedStatement
-
Field Summary
Fields inherited from class SQLite.JDBC2z.JDBCStatement
conn, maxrows, rs, updcntFields inherited from interface java.sql.Statement
CLOSE_ALL_RESULTS, CLOSE_CURRENT_RESULT, EXECUTE_FAILED, KEEP_CURRENT_RESULT, NO_GENERATED_KEYS, RETURN_GENERATED_KEYS, SUCCESS_NO_INFO -
Constructor Summary
Constructors Constructor Description JDBCPreparedStatement(JDBCConnection conn, String sql) -
Method Summary
Modifier and Type Method Description voidaddBatch()Add a set of parameters to thePreparedStatement's command batch.voidclearBatch()Clears the current list of SQL commands for this statement.voidclearParameters()Clear the current parameter values.voidclose()Releases this statement's database and JDBC driver resources.booleanexecute()Executes the SQL statement in thisPreparedStatement.int[]executeBatch()Submits a batch of SQL commands to the database.ResultSetexecuteQuery()Executes the SQL query in thePreparedStatementand returns theResultSetgenerated by the query.intexecuteUpdate()Invokes the SQL command contained within the prepared statement.ArraygetArray(int parameterIndex)ArraygetArray(String parameterName)BigDecimalgetBigDecimal(String parameterName)BlobgetBlob(int parameterIndex)BlobgetBlob(String parameterName)booleangetBoolean(String parameterName)bytegetByte(String parameterName)byte[]getBytes(String parameterName)ClobgetClob(int parameterIndex)ClobgetClob(String parameterName)DategetDate(int parameterIndex, Calendar cal)DategetDate(String parameterName)DategetDate(String parameterName, Calendar cal)doublegetDouble(String parameterName)floatgetFloat(String parameterName)intgetInt(String parameterName)longgetLong(String parameterName)ResultSetMetaDatagetMetaData()Returns aResultSetMetaDatadescribing theResultSetthat would be produced by execution of thePreparedStatement.ObjectgetObject(int parameterIndex)ObjectgetObject(int parameterIndex, Map map)ObjectgetObject(String parameterName)ObjectgetObject(String parameterName, Map map)ParameterMetaDatagetParameterMetaData()Gets information about the parameters of thePreparedStatement.RefgetRef(int parameterIndex)RefgetRef(String parameterName)shortgetShort(String parameterName)StringgetString(String parameterName)TimegetTime(int parameterIndex, Calendar cal)TimegetTime(String parameterName)TimegetTime(String parameterName, Calendar cal)TimestampgetTimestamp(int parameterIndex, Calendar cal)TimestampgetTimestamp(String parameterName)TimestampgetTimestamp(String parameterName, Calendar cal)URLgetURL(int parameterIndex)URLgetURL(String parameterName)voidregisterOutputParameter(String parameterName, int sqlType)voidregisterOutputParameter(String parameterName, int sqlType, int scale)voidregisterOutputParameter(String parameterName, int sqlType, String typeName)voidsetArray(int i, Array x)Sets the value of a specified parameter to the suppliedArray.voidsetAsciiStream(int parameterIndex, InputStream x)Sets the value of the specified parameter to the bytes frominputStream.voidsetAsciiStream(int parameterIndex, InputStream x, int length)Sets the value of a specified parameter to the content of a suppliedInputStream, which has a specified number of bytes.voidsetAsciiStream(int parameterIndex, InputStream x, long len)Sets the value of the specified parameter to the nextlengthbytes frominputStream.voidsetAsciiStream(String parameterName, InputStream x)voidsetAsciiStream(String parameterName, InputStream s, int length)voidsetAsciiStream(String parameterName, InputStream x, long len)voidsetBigDecimal(int parameterIndex, BigDecimal x)Sets the value of a specified parameter to a suppliedjava.math.BigDecimalvalue.voidsetBigDecimal(String parameterName, BigDecimal val)voidsetBinaryStream(int parameterIndex, InputStream x)Sets the value of the specified parameter to the bytes frominputStream.voidsetBinaryStream(int parameterIndex, InputStream x, int length)Sets the value of a specified parameter to the content of a supplied binaryInputStream, which has a specified number of bytes.voidsetBinaryStream(int parameterIndex, InputStream x, long len)Sets the value of the specified parameter to the nextlengthbytes frominputStream.voidsetBinaryStream(String parameterName, InputStream x)voidsetBinaryStream(String parameterName, InputStream s, int length)voidsetBinaryStream(String parameterName, InputStream x, long len)voidsetBlob(int parameterIndex, InputStream x)Sets the value of the specified parameter to the bytes frominputStream.voidsetBlob(int parameterIndex, InputStream x, long len)Sets the value of the specified parameter to the nextlengthbytes frominputStream.voidsetBlob(int i, Blob x)Sets the value of a specified parameter to the givenBlobobject.voidsetBlob(String parameterName, InputStream x)voidsetBlob(String parameterName, InputStream x, long len)voidsetBoolean(int parameterIndex, boolean x)Sets the value of a specified parameter to a suppliedbooleanvalue.voidsetBoolean(String parameterName, boolean val)voidsetByte(int parameterIndex, byte x)Sets the value of a specified parameter to a suppliedbytevalue.voidsetByte(String parameterName, byte val)voidsetBytes(int parameterIndex, byte[] x)Sets the value of a specified parameter to a supplied array of bytes.voidsetBytes(String parameterName, byte[] val)voidsetCharacterStream(int parameterIndex, Reader x)Sets the value of the specified parameter to the characters fromreader.voidsetCharacterStream(int parameterIndex, Reader reader, int length)Sets the value of a specified parameter to the character content of aReaderobject, with the specified length of character data.voidsetCharacterStream(int parameterIndex, Reader x, long len)Sets the value of the specified parameter to the nextlengthcharacters fromreader.voidsetCharacterStream(String parameterName, Reader x)voidsetCharacterStream(String parameterName, Reader r, int length)voidsetCharacterStream(String parameterName, Reader x, long len)voidsetClob(int parameterIndex, Reader x)Sets the value of the specified parameter to the characters fromreader.voidsetClob(int parameterIndex, Reader x, long len)Sets the value of the specified parameter to the nextlengthcharacters fromreader.voidsetClob(int i, Clob x)Sets the value of a specified parameter to the givenClobobject.voidsetClob(String parameterName, Reader x)voidsetClob(String parameterName, Reader x, long len)voidsetDate(int parameterIndex, Date x)Sets the value of a specified parameter to a suppliedjava.sql.Datevalue.voidsetDate(int parameterIndex, Date x, Calendar cal)Sets the value of a specified parameter to a suppliedjava.sql.Datevalue, using a suppliedCalendarto map the Date.voidsetDate(String parameterName, Date val)voidsetDate(String parameterName, Date val, Calendar cal)voidsetDouble(int parameterIndex, double x)Sets the value of a specified parameter to a supplieddoublevalue.voidsetDouble(String parameterName, double val)voidsetFloat(int parameterIndex, float x)Sets the value of a specified parameter to to a suppliedfloatvalue.voidsetFloat(String parameterName, float val)voidsetInt(int parameterIndex, int x)Sets the value of a specified parameter to a suppliedintvalue.voidsetInt(String parameterName, int val)voidsetLong(int parameterIndex, long x)Sets the value of a specified parameter to a suppliedlongvalue.voidsetLong(String parameterName, long val)voidsetNCharacterStream(int parameterIndex, Reader x)Sets the value of the specified parameter to the characters fromreader.voidsetNCharacterStream(int parameterIndex, Reader x, long len)Sets the value of the specified parameter to the nextlengthcharacters fromreader.voidsetNCharacterStream(String parameterName, Reader x)voidsetNCharacterStream(String parameterName, Reader x, long len)voidsetNClob(int parameterIndex, Reader x)Sets the value of the specified parameter to the characters fromreader.voidsetNClob(int parameterIndex, Reader x, long len)Sets the value of the specified parameter to the nextlengthcharacters fromreader.voidsetNClob(int parameterIndex, NClob value)Sets the value of the specified parameter tovalue.voidsetNClob(String parameterName, Reader x)voidsetNClob(String parameterName, Reader x, long len)voidsetNClob(String parameterName, NClob value)voidsetNString(int parameterIndex, String value)Sets the value of a specified parameter to a supplied string.voidsetNString(String parameterName, String value)voidsetNull(int parameterIndex, int sqlType)Sets the value of a specified parameter to SQLNULL.voidsetNull(int parameterIndex, int sqlType, String typeName)Sets the value of a specified parameter to SQLNULL.voidsetNull(String parameterName, int sqlType)voidsetNull(String parameterName, int sqlType, String typeName)voidsetObject(int parameterIndex, Object x)Sets the value of a specified parameter using a supplied object.voidsetObject(int parameterIndex, Object x, int targetSqlType)Sets the value of a specified parameter using a supplied object.voidsetObject(int parameterIndex, Object x, int targetSqlType, int scale)Sets the value of a specified parameter using a supplied object.voidsetObject(String parameterName, Object val)voidsetObject(String parameterName, Object val, int targetSqlType)voidsetObject(String parameterName, Object val, int targetSqlType, int scale)voidsetRef(int i, Ref x)Sets the value of a specified parameter to a suppliedREF(<structured-type>)value.voidsetRowId(int parameterIndex, RowId x)Sets the value of a specified parameter to a suppliedjava.sql.RowId.voidsetRowId(String parameterName, RowId x)voidsetShort(int parameterIndex, short x)Sets the value of a specified parameter to a suppliedshortvalue.voidsetShort(String parameterName, short val)voidsetSQLXML(int parameterIndex, SQLXML xml)Sets the value of the specified parameter to the value ofxmlObject.voidsetSQLXML(String parameterName, SQLXML xml)voidsetString(int parameterIndex, String x)Sets the value of a specified parameter to a supplied string.voidsetString(String parameterName, String val)voidsetTime(int parameterIndex, Time x)Sets the value of a specified parameter to a suppliedjava.sql.Timevalue.voidsetTime(int parameterIndex, Time x, Calendar cal)Sets the value of a specified parameter to a suppliedjava.sql.Timevalue, using a suppliedCalendar.voidsetTime(String parameterName, Time val)voidsetTime(String parameterName, Time val, Calendar cal)voidsetTimestamp(int parameterIndex, Timestamp x)Sets the value of a specified parameter to a supplied java.sql.Timestamp value.voidsetTimestamp(int parameterIndex, Timestamp x, Calendar cal)Sets the value of a specified parameter to a suppliedjava.sql.Timestampvalue, using the suppliedCalendar.voidsetTimestamp(String parameterName, Timestamp val)voidsetTimestamp(String parameterName, Timestamp val, Calendar cal)voidsetUnicodeStream(int parameterIndex, InputStream x, int length)Deprecated.voidsetURL(int parameterIndex, URL url)Sets the value of a specified parameter to a suppliedjava.net.URL.Methods inherited from class SQLite.JDBC2z.JDBCStatement
addBatch, cancel, clearWarnings, execute, execute, execute, execute, executeQuery, executeUpdate, executeUpdate, executeUpdate, executeUpdate, getConnection, getFetchDirection, getFetchSize, getGeneratedKeys, getMaxFieldSize, getMaxRows, getMoreResults, getMoreResults, getQueryTimeout, getResultSet, getResultSetConcurrency, getResultSetHoldability, getResultSetType, getUpdateCount, getWarnings, isClosed, isPoolable, isWrapperFor, setCursorName, setEscapeProcessing, setFetchDirection, setFetchSize, setMaxFieldSize, setMaxRows, setPoolable, setQueryTimeout, unwrapMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.sql.Statement
addBatch, cancel, clearWarnings, execute, execute, execute, execute, executeQuery, executeUpdate, executeUpdate, executeUpdate, executeUpdate, getConnection, getFetchDirection, getFetchSize, getGeneratedKeys, getMaxFieldSize, getMaxRows, getMoreResults, getMoreResults, getQueryTimeout, getResultSet, getResultSetConcurrency, getResultSetHoldability, getResultSetType, getUpdateCount, getWarnings, isClosed, isPoolable, setCursorName, setEscapeProcessing, setFetchDirection, setFetchSize, setMaxFieldSize, setMaxRows, setPoolable, setQueryTimeoutMethods inherited from interface java.sql.Wrapper
isWrapperFor, unwrap
-
Constructor Details
-
JDBCPreparedStatement
-
-
Method Details
-
executeQuery
Description copied from interface:PreparedStatementExecutes the SQL query in thePreparedStatementand returns theResultSetgenerated by the query.- Specified by:
executeQueryin interfacePreparedStatement- Returns:
- the
ResultSetgenerated by the query, nevernull. - Throws:
SQLException- if a database error happens or if the SQL statement does not produce aResultSet.
-
executeUpdate
Description copied from interface:PreparedStatementInvokes the SQL command contained within the prepared statement. This must beINSERT,UPDATE,DELETE, or a command that returns nothing.- Specified by:
executeUpdatein interfacePreparedStatement- Returns:
- the number of affected rows for
INSERT,UPDATEorDELETEstatements,0for statements that return nothing. - Throws:
SQLException- if a database error happens or if the SQL statement returns aResultSet.
-
setNull
Description copied from interface:PreparedStatementSets the value of a specified parameter to SQLNULL. Don't use this version ofsetNullfor User Defined Types (UDT) or for REF type parameters.- Specified by:
setNullin interfacePreparedStatement- Parameters:
parameterIndex- the parameter number index, where the first parameter has index 1.sqlType- the SQL type of the parameter, as defined injava.sql.Types.- Throws:
SQLException- if a database error happens.
-
setBoolean
Description copied from interface:PreparedStatementSets the value of a specified parameter to a suppliedbooleanvalue.- Specified by:
setBooleanin interfacePreparedStatement- Parameters:
parameterIndex- the parameter number index, where the first parameter has index 1.x- the boolean value to which the parameter atparameterIndexis set.- Throws:
SQLException- if a database error happens.
-
setByte
Description copied from interface:PreparedStatementSets the value of a specified parameter to a suppliedbytevalue.- Specified by:
setBytein interfacePreparedStatement- Parameters:
parameterIndex- the parameter number index, where the first parameter has index 1.x- the byte value to which the parameter atparameterIndexis set.- Throws:
SQLException- if a database error happens.
-
setShort
Description copied from interface:PreparedStatementSets the value of a specified parameter to a suppliedshortvalue.- Specified by:
setShortin interfacePreparedStatement- Parameters:
parameterIndex- the parameter number index, where the first parameter has index 1.x- ashortvalue to which the parameter atparameterIndexis set.- Throws:
SQLException- if a database error happens.
-
setInt
Description copied from interface:PreparedStatementSets the value of a specified parameter to a suppliedintvalue.- Specified by:
setIntin interfacePreparedStatement- Parameters:
parameterIndex- the parameter number index, where the first parameter has index 1.x- theintvalue to which the parameter atparameterIndexis set.- Throws:
SQLException- if a database error happens.
-
setLong
Description copied from interface:PreparedStatementSets the value of a specified parameter to a suppliedlongvalue.- Specified by:
setLongin interfacePreparedStatement- Parameters:
parameterIndex- the parameter number index, where the first parameter has index 1.x- thelongvalue to which the parameter atparameterIndexis set.- Throws:
SQLException- if a database error happens.
-
setFloat
Description copied from interface:PreparedStatementSets the value of a specified parameter to to a suppliedfloatvalue.- Specified by:
setFloatin interfacePreparedStatement- Parameters:
parameterIndex- the parameter number index, where the first parameter has index 1.x- thefloatvalue to update the parameter.- Throws:
SQLException- if a database error happens.
-
setDouble
Description copied from interface:PreparedStatementSets the value of a specified parameter to a supplieddoublevalue.- Specified by:
setDoublein interfacePreparedStatement- Parameters:
parameterIndex- the parameter number index, where the first parameter has index 1.x- thedoublevalue to which the parameter atparameterIndexis set.- Throws:
SQLException- if a database error happens.
-
setBigDecimal
Description copied from interface:PreparedStatementSets the value of a specified parameter to a suppliedjava.math.BigDecimalvalue.- Specified by:
setBigDecimalin interfacePreparedStatement- Parameters:
parameterIndex- the parameter number index, where the first parameter has index 1.x- the value to which the parameter atparameterIndexis set.- Throws:
SQLException- if a database error happens.- See Also:
BigDecimal
-
setString
Description copied from interface:PreparedStatementSets the value of a specified parameter to a supplied string.- Specified by:
setStringin interfacePreparedStatement- Parameters:
parameterIndex- the parameter number index, where the first parameter has index 1.x- the value to which the parameter atparameterIndexis set.- Throws:
SQLException- if a database error happens.
-
setBytes
Description copied from interface:PreparedStatementSets the value of a specified parameter to a supplied array of bytes. The array is mapped to aVARBINARYorLONGVARBINARYin the database.- Specified by:
setBytesin interfacePreparedStatement- Parameters:
parameterIndex- the parameter number index, where the first parameter has index 1.x- the array of bytes to which the parameter atparameterIndexis set.- Throws:
SQLException- if a database error happens.
-
setDate
Description copied from interface:PreparedStatementSets the value of a specified parameter to a suppliedjava.sql.Datevalue.- Specified by:
setDatein interfacePreparedStatement- Parameters:
parameterIndex- the parameter number index, where the first parameter has index 1.x- ajava.sql.Dateto which the parameter atparameterIndexis set.- Throws:
SQLException- if a database error happens.
-
setTime
Description copied from interface:PreparedStatementSets the value of a specified parameter to a suppliedjava.sql.Timevalue.- Specified by:
setTimein interfacePreparedStatement- Parameters:
parameterIndex- the parameter number index, where the first parameter has index 1.x- ajava.sql.Timevalue to which the parameter atparameterIndexis set.- Throws:
SQLException- if a database error happens.
-
setTimestamp
Description copied from interface:PreparedStatementSets the value of a specified parameter to a supplied java.sql.Timestamp value.- Specified by:
setTimestampin interfacePreparedStatement- Parameters:
parameterIndex- the parameter number index, where the first parameter has index 1.x- the java.sql.Timestamp value to which the parameter atparameterIndexis set.- Throws:
SQLException- if a database error happens.
-
setAsciiStream
Description copied from interface:PreparedStatementSets the value of a specified parameter to the content of a suppliedInputStream, which has a specified number of bytes.This is a good method for setting an SQL
LONGVARCHARparameter where the length of the data is large. Data is read from theInputStreamuntil end-of-file is reached or the specified number of bytes is copied.- Specified by:
setAsciiStreamin interfacePreparedStatement- Parameters:
parameterIndex- the parameter number index, where the first parameter has index 1.x- the ASCIIInputStreamcarrying the data to which the parameter atparameterIndexis set.length- the number of bytes in theInputStreamto copy to the parameter.- Throws:
SQLException- if a database error happens.
-
setUnicodeStream
@Deprecated public void setUnicodeStream(int parameterIndex, InputStream x, int length) throws SQLExceptionDeprecated.Description copied from interface:PreparedStatementSets the value of a specified parameter to the characters from a suppliedInputStream, with a specified number of bytes.- Specified by:
setUnicodeStreamin interfacePreparedStatement- Parameters:
parameterIndex- the parameter number index, where the first parameter has index 1.x- theInputStreamwith the character data to which the parameter atparameterIndexis set.length- the number of bytes to read from theInputStream.- Throws:
SQLException- if a database error happens.
-
setBinaryStream
Description copied from interface:PreparedStatementSets the value of a specified parameter to the content of a supplied binaryInputStream, which has a specified number of bytes.Use this method when a large amount of data needs to be set into a
LONGVARBINARYparameter.- Specified by:
setBinaryStreamin interfacePreparedStatement- Parameters:
parameterIndex- the parameter number index, where the first parameter has index 1.x- the binaryInputStreamcarrying the data to update the parameter.length- the number of bytes in theInputStreamto copy to the parameter.- Throws:
SQLException- if a database error happens.
-
clearParameters
Description copied from interface:PreparedStatementClear the current parameter values.Typically, parameter values are retained for multiple executions of the
Statement. Setting a parameter value replaces the previous value. This method clears the values for all parameters, releasing all resources used by those parameters.- Specified by:
clearParametersin interfacePreparedStatement- Throws:
SQLException- if a database error happens.
-
setObject
public void setObject(int parameterIndex, Object x, int targetSqlType, int scale) throws SQLExceptionDescription copied from interface:PreparedStatementSets the value of a specified parameter using a supplied object.The object is converted to the given
targetSqlTypebefore it is sent to the database. If the object has a custom mapping (its class implements the interfaceSQLData), the JDBC driver will call the methodSQLData.writeSQLto write it to the SQL data stream. If the object's class implementsRef,Blob,Clob,Struct, orArray, the driver will pass it to the database in the form of the relevant SQL type.- Specified by:
setObjectin interfacePreparedStatement- Parameters:
parameterIndex- the parameter index, where the first parameter has index 1.x- the Object containing the value to which the parameter atparameterIndexis set.targetSqlType- the SQL type to send to the database, as defined injava.sql.Types.scale- the number of digits after the decimal point - only applies to the typesjava.sql.Types.DECIMALandjava.sql.Types.NUMERIC- ignored for all other types.- Throws:
SQLException- if a database error happens.
-
setObject
Description copied from interface:PreparedStatementSets the value of a specified parameter using a supplied object.The object is converted to the given
targetSqlTypebefore it is sent to the database. If the object has a custom mapping (its class implements the interfaceSQLData), the JDBC driver will call the methodSQLData.writeSQLto write it to the SQL data stream. If the object's class implementsRef,Blob,Clob,Struct, orArray, the driver will pass it to the database in the form of the relevant SQL type.- Specified by:
setObjectin interfacePreparedStatement- Parameters:
parameterIndex- the parameter index, where the first parameter has index 1.x- the Object containing the value to which the parameter atparameterIndexis set.targetSqlType- the SQL type to send to the database, as defined injava.sql.Types.- Throws:
SQLException- if a database error happens.
-
setObject
Description copied from interface:PreparedStatementSets the value of a specified parameter using a supplied object.There is a standard mapping from Java types to SQL types, defined in the JDBC specification. The passed object is then transformed into the appropriate SQL type, and then transferred to the database.
setObjectcan be used to pass abstract data types unique to the database, by using a JDBC driver specific Java type. If the object's class implements the interfaceSQLData, the JDBC driver callsSQLData.writeSQLto write it to the SQL data stream. If the object's class implementsRef,Blob,Clob,Struct, orArray, the driver passes it to the database as a value of the corresponding SQL type.- Specified by:
setObjectin interfacePreparedStatement- Parameters:
parameterIndex- the parameter number index, where the first parameter has index 1.x- the object containing the value to which the parameter atparameterIndexis set.- Throws:
SQLException- if a database error happens.
-
execute
Description copied from interface:PreparedStatementExecutes the SQL statement in thisPreparedStatement.A
PreparedStatementmay return multiple results. The execute method executes thePreparedStatementand returns a flag indicating the kind of result produced by the action. The methodsgetResultSetorgetUpdateCountare used to retrieve the first result, and the second and subsequent results are retrieved withgetMoreResults.- Specified by:
executein interfacePreparedStatement- Returns:
trueif the result of the execution is aResultSet,falseif there is no result or if the result is an update count.- Throws:
SQLException- if a database error happens.
-
addBatch
Description copied from interface:PreparedStatementAdd a set of parameters to thePreparedStatement's command batch.- Specified by:
addBatchin interfacePreparedStatement- Throws:
SQLException- if a database error happens.
-
executeBatch
Description copied from interface:StatementSubmits a batch of SQL commands to the database. Returns an array of update counts, if all the commands execute successfully.If one of the commands in the batch fails, this method can throw a
BatchUpdateExceptionand the JDBC driver may or may not process the remaining commands. The JDBC driver must behave consistently with the underlying database, following the "all or nothing" principle. If the driver continues processing, the array of results returned contains the same number of elements as there are commands in the batch, with a minimum of one of the elements having theEXECUTE_FAILEDvalue.- Specified by:
executeBatchin interfaceStatement- Overrides:
executeBatchin classJDBCStatement- Returns:
- an array of update counts, with one entry for each command in the
batch. The elements are ordered according to the order in which
the commands were added to the batch.
- If the value of an element is ≥ 0, the corresponding command completed successfully and the value is the update count (the number of rows in the database affected by the command) for that command.
- If the value is
SUCCESS_NO_INFO, the command completed successfully but the number of rows affected is unknown. - If the value is
EXECUTE_FAILED, the command failed.
- Throws:
SQLException- if an error occurs accessing the database.
-
clearBatch
Description copied from interface:StatementClears the current list of SQL commands for this statement.- Specified by:
clearBatchin interfaceStatement- Overrides:
clearBatchin classJDBCStatement- Throws:
SQLException- if an error occurs accessing the database or the database does not support batch updates.
-
close
Description copied from interface:StatementReleases this statement's database and JDBC driver resources.Using this method to release these resources as soon as possible is strongly recommended.
One should not rely on the resources being automatically released when finalized during garbage collection. Doing so can result in unpredictable behavior for the application.
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceStatement- Overrides:
closein classJDBCStatement- Throws:
SQLException- if an error occurs accessing the database.
-
setCharacterStream
Description copied from interface:PreparedStatementSets the value of a specified parameter to the character content of aReaderobject, with the specified length of character data.Data is read from the
Readeruntil end-of-file is reached or the specified number of characters are copied.- Specified by:
setCharacterStreamin interfacePreparedStatement- Parameters:
parameterIndex- the parameter number index, where the first parameter has index 1reader- thejava.io.Readercontaining the character data.length- the number of characters to be read.- Throws:
SQLException- if a database error happens.
-
setRef
Description copied from interface:PreparedStatementSets the value of a specified parameter to a suppliedREF(<structured-type>)value. This is stored as an SQLREF.- Specified by:
setRefin interfacePreparedStatement- Parameters:
i- the parameter number index, where the first parameter has index 1.x- ajava.sql.Refvalue to which the parameter atparameterIndexis set.- Throws:
SQLException- if a database error happens.- See Also:
Ref
-
setBlob
Description copied from interface:PreparedStatementSets the value of a specified parameter to the givenBlobobject.- Specified by:
setBlobin interfacePreparedStatement- Parameters:
i- the parameter number index, where the first parameter has index 1.x- thejava.sql.Blobto which the parameter atparameterIndexis set.- Throws:
SQLException- if a database error happens.- See Also:
Blob
-
setClob
Description copied from interface:PreparedStatementSets the value of a specified parameter to the givenClobobject.- Specified by:
setClobin interfacePreparedStatement- Parameters:
i- the parameter number index, where the first parameter has index 1.x- ajava.sql.Clobholding the data to which the parameter atparameterIndexis set.- Throws:
SQLException- if a database error happens.
-
setArray
Description copied from interface:PreparedStatementSets the value of a specified parameter to the suppliedArray.- Specified by:
setArrayin interfacePreparedStatement- Parameters:
i- the parameter number index, where the first parameter has index 1.x- ajava.sql.Arraygiving the new value of the parameter atparameterIndex.- Throws:
SQLException- if a database error happens.- See Also:
Array
-
getMetaData
Description copied from interface:PreparedStatementReturns aResultSetMetaDatadescribing theResultSetthat would be produced by execution of thePreparedStatement.It is possible to know the metadata for the
ResultSetwithout executing thePreparedStatement, because thePreparedStatementis precompiled. As a result the metadata can be queried ahead of time without actually executing the statement.- Specified by:
getMetaDatain interfacePreparedStatement- Returns:
- a
ResultSetMetaDataobject with the information about the columns of theResultSet, if the driver can return aResultSetMetaData.nullotherwise. - Throws:
SQLException- if there is a database error.
-
setDate
Description copied from interface:PreparedStatementSets the value of a specified parameter to a suppliedjava.sql.Datevalue, using a suppliedCalendarto map the Date. TheCalendarallows the application to control the timezone used to compute the SQLDATEin the database - without the suppliedCalendar, the driver uses the VM defaults. See "Be wary of the default locale".- Specified by:
setDatein interfacePreparedStatement- Parameters:
parameterIndex- the parameter number index, where the first parameter has index 1.x- ajava.sql.Dateto which the parameter atparameterIndexis set.cal- aCalendarto use to construct the SQLDATEvalue.- Throws:
SQLException- if a database error happens.- See Also:
Date,Calendar
-
setTime
Description copied from interface:PreparedStatementSets the value of a specified parameter to a suppliedjava.sql.Timevalue, using a suppliedCalendar.The driver uses the supplied
Calendarto create the SQLTIMEvalue, which allows it to use a custom timezone - otherwise the driver uses the VM defaults. See "Be wary of the default locale".- Specified by:
setTimein interfacePreparedStatement- Parameters:
parameterIndex- the parameter number index, where the first parameter has index 1.x- ajava.sql.Timevalue to which the parameter atparameterIndexis set.cal- aCalendarto use to construct the SQLTIMEvalue.- Throws:
SQLException- if a database error happens.- See Also:
Time,Calendar
-
setTimestamp
Description copied from interface:PreparedStatementSets the value of a specified parameter to a suppliedjava.sql.Timestampvalue, using the suppliedCalendar.The driver uses the supplied
Calendarto create the SQLTIMESTAMPvalue, which allows it to use a custom timezone - otherwise the driver uses the VM defaults. See "Be wary of the default locale".- Specified by:
setTimestampin interfacePreparedStatement- Parameters:
parameterIndex- the parameter number index, where the first parameter has index 1.x- thejava.sql.Timestampvalue to which the parameter atparameterIndexis set.cal- aCalendarto use to construct the SQLTIMESTAMPvalue- Throws:
SQLException- if a database error happens.- See Also:
Timestamp,Calendar
-
setNull
Description copied from interface:PreparedStatementSets the value of a specified parameter to SQLNULL. This version ofsetNullshould be used for User Defined Types (UDTs) and also REF types. UDTs can beSTRUCT,DISTINCT,JAVA_OBJECTand named array types.Applications must provide the SQL type code and also a fully qualified SQL type name when supplying a
NULLUDT or REF. For a UDT, the type name is the type name of the parameter itself, but for a REF parameter the type name is the type name of the referenced type.- Specified by:
setNullin interfacePreparedStatement- Parameters:
parameterIndex- the parameter number index, where the first parameter has index 1.sqlType- the SQL type of the parameter, as defined injava.sql.Types.typeName- the fully qualified name of a UDT or REF type - ignored if the parameter is not a UDT.- Throws:
SQLException- if a database error happens.- See Also:
Types
-
getParameterMetaData
Description copied from interface:PreparedStatementGets information about the parameters of thePreparedStatement.- Specified by:
getParameterMetaDatain interfacePreparedStatement- Returns:
- a
ParameterMetaDataobject which holds information about the number, type, and properties of the parameters of thisPreparedStatement. - Throws:
SQLException- if a database error happens.
-
registerOutputParameter
- Throws:
SQLException
-
registerOutputParameter
public void registerOutputParameter(String parameterName, int sqlType, int scale) throws SQLException- Throws:
SQLException
-
registerOutputParameter
public void registerOutputParameter(String parameterName, int sqlType, String typeName) throws SQLException- Throws:
SQLException
-
getURL
- Throws:
SQLException
-
setURL
Description copied from interface:PreparedStatementSets the value of a specified parameter to a suppliedjava.net.URL.- Specified by:
setURLin interfacePreparedStatement- Parameters:
parameterIndex- the parameter number index, where the first parameter has index 1.url- theURLto which the parameter atparameterIndexis set.- Throws:
SQLException- if a database error happens.- See Also:
URL
-
setNull
- Throws:
SQLException
-
setBoolean
- Throws:
SQLException
-
setByte
- Throws:
SQLException
-
setShort
- Throws:
SQLException
-
setInt
- Throws:
SQLException
-
setLong
- Throws:
SQLException
-
setFloat
- Throws:
SQLException
-
setDouble
- Throws:
SQLException
-
setBigDecimal
- Throws:
SQLException
-
setString
- Throws:
SQLException
-
setBytes
- Throws:
SQLException
-
setDate
- Throws:
SQLException
-
setTime
- Throws:
SQLException
-
setTimestamp
- Throws:
SQLException
-
setAsciiStream
- Throws:
SQLException
-
setBinaryStream
- Throws:
SQLException
-
setObject
public void setObject(String parameterName, Object val, int targetSqlType, int scale) throws SQLException- Throws:
SQLException
-
setObject
- Throws:
SQLException
-
setObject
- Throws:
SQLException
-
setCharacterStream
- Throws:
SQLException
-
setDate
- Throws:
SQLException
-
setTime
- Throws:
SQLException
-
setTimestamp
- Throws:
SQLException
-
setNull
- Throws:
SQLException
-
getString
- Throws:
SQLException
-
getBoolean
- Throws:
SQLException
-
getByte
- Throws:
SQLException
-
getShort
- Throws:
SQLException
-
getInt
- Throws:
SQLException
-
getLong
- Throws:
SQLException
-
getFloat
- Throws:
SQLException
-
getDouble
- Throws:
SQLException
-
getBytes
- Throws:
SQLException
-
getDate
- Throws:
SQLException
-
getTime
- Throws:
SQLException
-
getTimestamp
- Throws:
SQLException
-
getObject
- Throws:
SQLException
-
getObject
- Throws:
SQLException
-
getBigDecimal
- Throws:
SQLException
-
getObject
- Throws:
SQLException
-
getObject
- Throws:
SQLException
-
getRef
- Throws:
SQLException
-
getRef
- Throws:
SQLException
-
getBlob
- Throws:
SQLException
-
getBlob
- Throws:
SQLException
-
getClob
- Throws:
SQLException
-
getClob
- Throws:
SQLException
-
getArray
- Throws:
SQLException
-
getArray
- Throws:
SQLException
-
getDate
- Throws:
SQLException
-
getDate
- Throws:
SQLException
-
getTime
- Throws:
SQLException
-
getTime
- Throws:
SQLException
-
getTimestamp
- Throws:
SQLException
-
getTimestamp
- Throws:
SQLException
-
getURL
- Throws:
SQLException
-
setRowId
Description copied from interface:PreparedStatementSets the value of a specified parameter to a suppliedjava.sql.RowId.- Specified by:
setRowIdin interfacePreparedStatement- Parameters:
parameterIndex- the parameter number index, where the first parameter has index 1.x- theRowIdto which the parameter atparameterIndexis set.- Throws:
SQLException- if a database error happens.
-
setRowId
- Throws:
SQLException
-
setNString
Description copied from interface:PreparedStatementSets the value of a specified parameter to a supplied string.- Specified by:
setNStringin interfacePreparedStatement- Parameters:
parameterIndex- the parameter number index, where the first parameter has index 1.value- theStringto which the parameter atparameterIndexis set.- Throws:
SQLException- if a database error happens.
-
setNString
- Throws:
SQLException
-
setNCharacterStream
Description copied from interface:PreparedStatementSets the value of the specified parameter to the nextlengthcharacters fromreader.- Specified by:
setNCharacterStreamin interfacePreparedStatement- Parameters:
parameterIndex- the parameter number index, where the first parameter has index 1.x- theReaderlen- character count- Throws:
SQLException- if a database error happens.
-
setNCharacterStream
- Throws:
SQLException
-
setNClob
Description copied from interface:PreparedStatementSets the value of the specified parameter tovalue.- Specified by:
setNClobin interfacePreparedStatement- Parameters:
parameterIndex- the parameter number index, where the first parameter has index 1.value- theNClobto which the parameter atparameterIndexis set.- Throws:
SQLException- if a database error happens.
-
setNClob
- Throws:
SQLException
-
setClob
Description copied from interface:PreparedStatementSets the value of the specified parameter to the nextlengthcharacters fromreader.- Specified by:
setClobin interfacePreparedStatement- Parameters:
parameterIndex- the parameter number index, where the first parameter has index 1.x- theReaderlen- character count- Throws:
SQLException- if a database error happens.
-
setClob
- Throws:
SQLException
-
setBlob
Description copied from interface:PreparedStatementSets the value of the specified parameter to the nextlengthbytes frominputStream.- Specified by:
setBlobin interfacePreparedStatement- Parameters:
parameterIndex- the parameter number index, where the first parameter has index 1.x- theInputStreamlen- character count- Throws:
SQLException- if a database error happens.
-
setBlob
- Throws:
SQLException
-
setNClob
Description copied from interface:PreparedStatementSets the value of the specified parameter to the nextlengthcharacters fromreader.- Specified by:
setNClobin interfacePreparedStatement- Parameters:
parameterIndex- the parameter number index, where the first parameter has index 1.x- theReaderlen- character count- Throws:
SQLException- if a database error happens.
-
setNClob
- Throws:
SQLException
-
setSQLXML
Description copied from interface:PreparedStatementSets the value of the specified parameter to the value ofxmlObject.- Specified by:
setSQLXMLin interfacePreparedStatement- Parameters:
parameterIndex- the parameter number index, where the first parameter has index 1.xml- theSQLXML- Throws:
SQLException- if a database error happens.
-
setSQLXML
- Throws:
SQLException
-
setAsciiStream
Description copied from interface:PreparedStatementSets the value of the specified parameter to the nextlengthbytes frominputStream.- Specified by:
setAsciiStreamin interfacePreparedStatement- Parameters:
parameterIndex- the parameter number index, where the first parameter has index 1.x- theInputStreamlen- character count- Throws:
SQLException- if a database error happens.
-
setAsciiStream
- Throws:
SQLException
-
setBinaryStream
Description copied from interface:PreparedStatementSets the value of the specified parameter to the nextlengthbytes frominputStream.- Specified by:
setBinaryStreamin interfacePreparedStatement- Parameters:
parameterIndex- the parameter number index, where the first parameter has index 1.x- theInputStreamlen- character count- Throws:
SQLException- if a database error happens.
-
setBinaryStream
- Throws:
SQLException
-
setCharacterStream
Description copied from interface:PreparedStatementSets the value of the specified parameter to the nextlengthcharacters fromreader.- Specified by:
setCharacterStreamin interfacePreparedStatement- Parameters:
parameterIndex- the parameter number index, where the first parameter has index 1.x- theReaderlen- character count- Throws:
SQLException- if a database error happens.
-
setCharacterStream
- Throws:
SQLException
-
setAsciiStream
Description copied from interface:PreparedStatementSets the value of the specified parameter to the bytes frominputStream.- Specified by:
setAsciiStreamin interfacePreparedStatement- Parameters:
parameterIndex- the parameter number index, where the first parameter has index 1.x- theInputStream- Throws:
SQLException- if a database error happens.
-
setAsciiStream
- Throws:
SQLException
-
setBinaryStream
Description copied from interface:PreparedStatementSets the value of the specified parameter to the bytes frominputStream.- Specified by:
setBinaryStreamin interfacePreparedStatement- Parameters:
parameterIndex- the parameter number index, where the first parameter has index 1.x- theInputStream- Throws:
SQLException- if a database error happens.
-
setBinaryStream
- Throws:
SQLException
-
setCharacterStream
Description copied from interface:PreparedStatementSets the value of the specified parameter to the characters fromreader.- Specified by:
setCharacterStreamin interfacePreparedStatement- Parameters:
parameterIndex- the parameter number index, where the first parameter has index 1.x- theReader- Throws:
SQLException- if a database error happens.
-
setCharacterStream
- Throws:
SQLException
-
setNCharacterStream
Description copied from interface:PreparedStatementSets the value of the specified parameter to the characters fromreader.- Specified by:
setNCharacterStreamin interfacePreparedStatement- Parameters:
parameterIndex- the parameter number index, where the first parameter has index 1.x- theReader- Throws:
SQLException- if a database error happens.
-
setNCharacterStream
- Throws:
SQLException
-
setClob
Description copied from interface:PreparedStatementSets the value of the specified parameter to the characters fromreader.- Specified by:
setClobin interfacePreparedStatement- Parameters:
parameterIndex- the parameter number index, where the first parameter has index 1.x- theReader- Throws:
SQLException- if a database error happens.
-
setClob
- Throws:
SQLException
-
setBlob
Description copied from interface:PreparedStatementSets the value of the specified parameter to the bytes frominputStream.- Specified by:
setBlobin interfacePreparedStatement- Parameters:
parameterIndex- the parameter number index, where the first parameter has index 1.x- theInputStream- Throws:
SQLException- if a database error happens.
-
setBlob
- Throws:
SQLException
-
setNClob
Description copied from interface:PreparedStatementSets the value of the specified parameter to the characters fromreader.- Specified by:
setNClobin interfacePreparedStatement- Parameters:
parameterIndex- the parameter number index, where the first parameter has index 1.x- theReader- Throws:
SQLException- if a database error happens.
-
setNClob
- Throws:
SQLException
-