Class BasePrepareStatement
- java.lang.Object
-
- org.mariadb.jdbc.MariaDbStatement
-
- org.mariadb.jdbc.BasePrepareStatement
-
- All Implemented Interfaces:
AutoCloseable,Cloneable,PreparedStatement,Statement,Wrapper
- Direct Known Subclasses:
ClientSidePreparedStatement,ServerSidePreparedStatement
public abstract class BasePrepareStatement extends MariaDbStatement implements PreparedStatement
-
-
Field Summary
Fields Modifier and Type Field Description protected intautoGeneratedKeysstatic DateTimeFormatterSPEC_ISO_ZONED_DATE_TIMEThe ISO-like date-time formatter that formats or parses a date-time with offset and zone, such as '2011-12-03T10:15:30+01:00[Europe/Paris]'.-
Fields inherited from class org.mariadb.jdbc.MariaDbStatement
canUseServerTimeout, closed, connection, exceptionFactory, executing, fetchSize, lock, maxRows, options, protocol, queryTimeout, results, resultSetConcurrency, resultSetScrollType
-
Fields inherited from interface java.sql.Statement
CLOSE_ALL_RESULTS, CLOSE_CURRENT_RESULT, EXECUTE_FAILED, KEEP_CURRENT_RESULT, NO_GENERATED_KEYS, RETURN_GENERATED_KEYS, SUCCESS_NO_INFO
-
-
Constructor Summary
Constructors Constructor Description BasePrepareStatement(MariaDbConnection connection, int resultSetScrollType, int resultSetConcurrency, int autoGeneratedKeys, ExceptionFactory exceptionFactory)Constructor.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description BasePrepareStatementclone(MariaDbConnection connection)Clone cached object.protected abstract booleanexecuteInternal(int fetchSize)longexecuteLargeUpdate()abstract ParameterMetaDatagetParameterMetaData()Retrieves the number, types and properties of thisPreparedStatementobject's parameters.voidsetArray(int parameterIndex, Array array)Sets the designated parameter to the givenjava.sql.Arrayobject.voidsetAsciiStream(int parameterIndex, InputStream stream)This function reads up the entire stream and stores it in memory since we need to know the length when sending it to the server use the corresponding method with a length parameter if memory is an issue
Sets the designated parameter to the given input stream.voidsetAsciiStream(int parameterIndex, InputStream stream, int length)Sets the designated parameter to the given input stream, which will have the specified number of bytes.voidsetAsciiStream(int parameterIndex, InputStream stream, long length)Sets the designated parameter to the given input stream, which will have the specified number of bytes.voidsetBigDecimal(int parameterIndex, BigDecimal bigDecimal)Sets the designated parameter to the givenjava.math.BigDecimalvalue.voidsetBinaryStream(int parameterIndex, InputStream stream)This function reads up the entire stream and stores it in memory since we need to know the length when sending it to the server
Sets the designated parameter to the given input stream.voidsetBinaryStream(int parameterIndex, InputStream stream, int length)Sets the designated parameter to the given input stream, which will have the specified number of bytes.voidsetBinaryStream(int parameterIndex, InputStream stream, long length)Sets the designated parameter to the given input stream, which will have the specified number of bytes.voidsetBlob(int parameterIndex, InputStream inputStream)Sets the designated parameter to aInputStreamobject.voidsetBlob(int parameterIndex, InputStream inputStream, long length)Sets the designated parameter to aInputStreamobject.voidsetBlob(int parameterIndex, Blob blob)Sets the designated parameter to the givenjava.sql.Blobobject.voidsetBoolean(int parameterIndex, boolean value)Sets the designated parameter to the given Javabooleanvalue.voidsetByte(int parameterIndex, byte bit)Sets the designated parameter to the given Javabytevalue.voidsetBytes(int parameterIndex, byte[] bytes)Sets the designated parameter to the given Java array of bytes.voidsetCharacterStream(int parameterIndex, Reader reader)Sets the designated parameter to the givenReaderobject.voidsetCharacterStream(int parameterIndex, Reader reader, int length)Sets the designated parameter to the givenReaderobject, which is the given number of characters long.voidsetCharacterStream(int parameterIndex, Reader reader, long length)Sets the designated parameter to the givenReaderobject, which is the given number of characters long.voidsetClob(int parameterIndex, Reader reader)Sets the designated parameter to aReaderobject.voidsetClob(int parameterIndex, Reader reader, long length)Sets the designated parameter to aReaderobject.voidsetClob(int parameterIndex, Clob clob)Sets the designated parameter to the givenjava.sql.Clobobject.voidsetDate(int parameterIndex, Date date)Sets the designated parameter to the givenjava.sql.Datevalue using the default time zone of the virtual machine that is running the application.voidsetDate(int parameterIndex, Date date, Calendar cal)Sets the designated parameter to the givenjava.sql.Datevalue, using the givenCalendarobject.voidsetDouble(int parameterIndex, double value)Sets the designated parameter to the given Javadoublevalue.voidsetFloat(int parameterIndex, float value)Sets the designated parameter to the given Javafloatvalue.voidsetInt(int column, int value)voidsetLong(int parameterIndex, long value)Sets the designated parameter to the given Javalongvalue.voidsetNCharacterStream(int parameterIndex, Reader value)Sets the designated parameter to aReaderobject.voidsetNCharacterStream(int parameterIndex, Reader value, long length)Sets the designated parameter to aReaderobject.voidsetNClob(int parameterIndex, Reader reader)Sets the designated parameter to aReaderobject.voidsetNClob(int parameterIndex, Reader reader, long length)Sets the designated parameter to aReaderobject.voidsetNClob(int parameterIndex, NClob value)Sets the designated parameter to ajava.sql.NClobobject.voidsetNString(int parameterIndex, String value)Sets the designated parameter to the givenStringobject.voidsetNull(int parameterIndex, int sqlType)Sets the designated parameter to SQLNULL.voidsetNull(int parameterIndex, int sqlType, String typeName)Sets the designated parameter to SQLNULL.voidsetNull(int parameterIndex, ColumnType mariadbType)Sets the designated parameter to SQLNULL.voidsetObject(int parameterIndex, Object obj)Sets the value of the designated parameter using the given object.voidsetObject(int parameterIndex, Object obj, int targetSqlType)Sets the value of the designated parameter with the given object.voidsetObject(int parameterIndex, Object obj, int targetSqlType, int scaleOrLength)Sets the value of the designated parameter with the given object.voidsetObject(int parameterIndex, Object obj, SQLType targetSqlType)voidsetObject(int parameterIndex, Object obj, SQLType targetSqlType, int scaleOrLength)abstract voidsetParameter(int parameterIndex, ParameterHolder holder)voidsetRef(int parameterIndex, Ref ref)Sets the designated parameter to the givenREF(<structured-type>)value.voidsetRowId(int parameterIndex, RowId rowid)Sets the designated parameter to the givenjava.sql.RowIdobject.voidsetShort(int parameterIndex, short value)Sets the designated parameter to the given Javashortvalue.voidsetSQLXML(int parameterIndex, SQLXML xmlObject)Sets the designated parameter to the givenjava.sql.SQLXMLobject.voidsetString(int parameterIndex, String str)Set string parameter.voidsetTime(int parameterIndex, Time time)Sets the designated parameter to the givenjava.sql.Timevalue.voidsetTime(int parameterIndex, Time time, Calendar cal)Sets the designated parameter to the givenjava.sql.Timevalue, using the givenCalendarobject.voidsetTimestamp(int parameterIndex, Timestamp timestamp)Sets the designated parameter to the givenjava.sql.Timestampvalue.voidsetTimestamp(int parameterIndex, Timestamp timestamp, Calendar cal)Sets the designated parameter to the givenjava.sql.Timestampvalue, using the givenCalendarobject.voidsetUnicodeStream(int parameterIndex, InputStream x, int length)Deprecated.deprecatedvoidsetURL(int parameterIndex, URL url)Sets the designated parameter to the givenjava.net.URLvalue.-
Methods inherited from class org.mariadb.jdbc.MariaDbStatement
addBatch, cancel, checkClose, checkCloseOnCompletion, clearBatch, clearWarnings, close, closeOnCompletion, enquoteIdentifier, enquoteLiteral, enquoteNCharLiteral, execute, execute, execute, execute, executeBatch, executeBatchEpilogue, executeBatchExceptionEpilogue, executeEpilogue, executeExceptionEpilogue, executeLargeBatch, executeLargeUpdate, executeLargeUpdate, executeLargeUpdate, executeLargeUpdate, executeQuery, executeQueryPrologue, executeUpdate, executeUpdate, executeUpdate, executeUpdate, getConnection, getFetchDirection, getFetchSize, getGeneratedKeys, getLargeMaxRows, getLargeUpdateCount, getMaxFieldSize, getMaxRows, getMoreResults, getMoreResults, getQueryTimeout, getResultSet, getResultSetConcurrency, getResultSetHoldability, getResultSetType, getUpdateCount, getWarnings, isClosed, isCloseOnCompletion, isPoolable, isSimpleIdentifier, isWrapperFor, setCursorName, setEscapeProcessing, setFetchDirection, setFetchSize, setLargeMaxRows, setLocalInfileInputStream, setMaxFieldSize, setMaxRows, setPoolable, setQueryTimeout, setTimerTask, skipMoreResults, testExecute, unwrap
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.sql.PreparedStatement
addBatch, clearParameters, execute, executeQuery, executeUpdate, getMetaData
-
Methods inherited from interface java.sql.Statement
addBatch, cancel, clearBatch, clearWarnings, close, closeOnCompletion, enquoteIdentifier, enquoteLiteral, enquoteNCharLiteral, execute, execute, execute, execute, executeBatch, executeLargeBatch, executeLargeUpdate, executeLargeUpdate, executeLargeUpdate, executeLargeUpdate, executeQuery, executeUpdate, executeUpdate, executeUpdate, executeUpdate, getConnection, getFetchDirection, getFetchSize, getGeneratedKeys, getLargeMaxRows, getLargeUpdateCount, getMaxFieldSize, getMaxRows, getMoreResults, getMoreResults, getQueryTimeout, getResultSet, getResultSetConcurrency, getResultSetHoldability, getResultSetType, getUpdateCount, getWarnings, isClosed, isCloseOnCompletion, isPoolable, isSimpleIdentifier, setCursorName, setEscapeProcessing, setFetchDirection, setFetchSize, setLargeMaxRows, setMaxFieldSize, setMaxRows, setPoolable, setQueryTimeout
-
Methods inherited from interface java.sql.Wrapper
isWrapperFor, unwrap
-
-
-
-
Field Detail
-
SPEC_ISO_ZONED_DATE_TIME
public static final DateTimeFormatter SPEC_ISO_ZONED_DATE_TIME
The ISO-like date-time formatter that formats or parses a date-time with offset and zone, such as '2011-12-03T10:15:30+01:00[Europe/Paris]'. and without the 'T' time delimiterThis returns an immutable formatter capable of formatting and parsing a format that extends the ISO-8601 extended offset date-time format to add the time-zone.
-
autoGeneratedKeys
protected int autoGeneratedKeys
-
-
Constructor Detail
-
BasePrepareStatement
public BasePrepareStatement(MariaDbConnection connection, int resultSetScrollType, int resultSetConcurrency, int autoGeneratedKeys, ExceptionFactory exceptionFactory)
Constructor. Base class that permit setting parameters for client and server PrepareStatement.- Parameters:
connection- current connectionresultSetScrollType- one of the followingResultSetconstants:ResultSet.TYPE_FORWARD_ONLY,ResultSet.TYPE_SCROLL_INSENSITIVE, orResultSet.TYPE_SCROLL_SENSITIVEresultSetConcurrency- one of the followingResultSetconstants:ResultSet.CONCUR_READ_ONLYorResultSet.CONCUR_UPDATABLEautoGeneratedKeys- a flag indicating whether auto-generated keys should be returned; one ofStatement.RETURN_GENERATED_KEYSorStatement.NO_GENERATED_KEYSexceptionFactory- exception factory
-
-
Method Detail
-
clone
public BasePrepareStatement clone(MariaDbConnection connection) throws CloneNotSupportedException
Clone cached object.- Overrides:
clonein classMariaDbStatement- Parameters:
connection- connection- Returns:
- BasePrepareStatement
- Throws:
CloneNotSupportedException- if cloning exception
-
executeLargeUpdate
public long executeLargeUpdate() throws SQLException- Specified by:
executeLargeUpdatein interfacePreparedStatement- Throws:
SQLException
-
executeInternal
protected abstract boolean executeInternal(int fetchSize) throws SQLException- Throws:
SQLException
-
setCharacterStream
public void setCharacterStream(int parameterIndex, Reader reader, int length) throws SQLExceptionSets the designated parameter to the givenReaderobject, which is the given number of characters long. When a very large UNICODE value is input to aLONGVARCHARparameter, it may be more practical to send it via ajava.io.Readerobject. The data will be read from the stream as needed until end-of-file is reached. The JDBC driver will do any necessary conversion from UNICODE to the database char format.Note: This stream object can either be a standard Java stream object or your own subclass that implements the standard interface.
- Specified by:
setCharacterStreamin interfacePreparedStatement- Parameters:
parameterIndex- the first parameter is 1, the second is 2, ...reader- thejava.io.Readerobject that contains the Unicode datalength- the number of characters in the stream- Throws:
SQLException- if parameterIndex does not correspond to a parameter marker in the SQL statement; if a database access error occurs or this method is called on a closedPreparedStatement
-
setCharacterStream
public void setCharacterStream(int parameterIndex, Reader reader, long length) throws SQLExceptionSets the designated parameter to the givenReaderobject, which is the given number of characters long. When a very large UNICODE value is input to aLONGVARCHARparameter, it may be more practical to send it via ajava.io.Readerobject. The data will be read from the stream as needed until end-of-file is reached. The JDBC driver will do any necessary conversion from UNICODE to the database char format.Note: This stream object can either be a standard Java stream object or your own subclass that implements the standard interface.
- Specified by:
setCharacterStreamin interfacePreparedStatement- Parameters:
parameterIndex- the first parameter is 1, the second is 2, ...reader- thejava.io.Readerobject that contains the Unicode datalength- the number of characters in the stream- Throws:
SQLException- if parameterIndex does not correspond to a parameter marker in the SQL statement; if a database access error occurs or this method is called on a closedPreparedStatement
-
setCharacterStream
public void setCharacterStream(int parameterIndex, Reader reader) throws SQLExceptionSets the designated parameter to the givenReaderobject. When a very large UNICODE value is input to aLONGVARCHARparameter, it may be more practical to send it via ajava.io.Readerobject. The data will be read from the stream as needed until end-of-file is reached. The JDBC driver will do any necessary conversion from UNICODE to the database char format.Note: This stream object can either be a standard Java stream object or your own subclass that implements the standard interface.
Note: Consult your JDBC driver documentation to determine if it might be more efficient to use a version of
setCharacterStreamwhich takes a length parameter.- Specified by:
setCharacterStreamin interfacePreparedStatement- Parameters:
parameterIndex- the first parameter is 1, the second is 2, ...reader- thejava.io.Readerobject that contains the Unicode data- Throws:
SQLException- if parameterIndex does not correspond to a parameter marker in the SQL statement; if a database access error occurs or this method is called on a closedPreparedStatement
-
setRef
public void setRef(int parameterIndex, Ref ref) throws SQLExceptionSets the designated parameter to the givenREF(<structured-type>)value. The driver converts this to an SQLREFvalue when it sends it to the database.- Specified by:
setRefin interfacePreparedStatement- Parameters:
parameterIndex- the first parameter is 1, the second is 2, ...ref- an SQLREFvalue- Throws:
SQLException- if parameterIndex does not correspond to a parameter marker in the SQL statement; if a database access error occurs or this method is called on a closedPreparedStatement
-
setBlob
public void setBlob(int parameterIndex, Blob blob) throws SQLExceptionSets the designated parameter to the givenjava.sql.Blobobject. The driver converts this to an SQLBLOBvalue when it sends it to the database.- Specified by:
setBlobin interfacePreparedStatement- Parameters:
parameterIndex- the first parameter is 1, the second is 2, ...blob- aBlobobject that maps an SQLBLOBvalue- Throws:
SQLException- if parameterIndex does not correspond to a parameter marker in the SQL statement; if a database access error occurs or this method is called on a closedPreparedStatement
-
setBlob
public void setBlob(int parameterIndex, InputStream inputStream, long length) throws SQLExceptionSets the designated parameter to aInputStreamobject. The inputstream must contain the number of characters specified by length otherwise aSQLExceptionwill be generated when thePreparedStatementis executed. This method differs from thesetBinaryStream (int, InputStream, int)method because it informs the driver that the parameter value should be sent to the server as aBLOB. When thesetBinaryStreammethod is used, the driver may have to do extra work to determine whether the parameter data should be sent to the server as aLONGVARBINARYor aBLOB- Specified by:
setBlobin interfacePreparedStatement- Parameters:
parameterIndex- index of the first parameter is 1, the second is 2, ...inputStream- An object that contains the data to set the parameter value to.length- the number of bytes in the parameter data.- Throws:
SQLException- if parameterIndex does not correspond to a parameter marker in the SQL statement; if a database access error occurs; this method is called on a closedPreparedStatement; if the length specified is less than zero or if the number of bytes in the inputstream does not match the specfied length.
-
setBlob
public void setBlob(int parameterIndex, InputStream inputStream) throws SQLExceptionSets the designated parameter to aInputStreamobject. This method differs from thesetBinaryStream (int, InputStream)method because it informs the driver that the parameter value should be sent to the server as aBLOB. When thesetBinaryStreammethod is used, the driver may have to do extra work to determine whether the parameter data should be sent to the server as aLONGVARBINARYor aBLOBNote: Consult your JDBC driver documentation to determine if it might be more efficient to use a version of
setBlobwhich takes a length parameter.- Specified by:
setBlobin interfacePreparedStatement- Parameters:
parameterIndex- index of the first parameter is 1, the second is 2, ...inputStream- An object that contains the data to set the parameter value to.- Throws:
SQLException- if parameterIndex does not correspond to a parameter marker in the SQL statement; if a database access error occurs; this method is called on a closedPreparedStatementor if parameterIndex does not correspond to a parameter marker in the SQL statement,
-
setClob
public void setClob(int parameterIndex, Clob clob) throws SQLExceptionSets the designated parameter to the givenjava.sql.Clobobject. The driver converts this to an SQLCLOBvalue when it sends it to the database.- Specified by:
setClobin interfacePreparedStatement- Parameters:
parameterIndex- the first parameter is 1, the second is 2, ...clob- aClobobject that maps an SQLCLOBvalue- Throws:
SQLException- if parameterIndex does not correspond to a parameter marker in the SQL statement; if a database access error occurs or this method is called on a closedPreparedStatement
-
setClob
public void setClob(int parameterIndex, Reader reader, long length) throws SQLExceptionSets the designated parameter to aReaderobject. The reader must contain the number of characters specified by length otherwise aSQLExceptionwill be generated when thePreparedStatementis executed. This method differs from thesetCharacterStream (int, Reader, int)method because it informs the driver that the parameter value should be sent to the server as aCLOB. When thesetCharacterStreammethod is used, the driver may have to do extra work to determine whether the parameter data should be sent to the server as aLONGVARCHARor aCLOB- Specified by:
setClobin interfacePreparedStatement- Parameters:
parameterIndex- index of the first parameter is 1, the second is 2, ...reader- An object that contains the data to set the parameter value to.length- the number of characters in the parameter data.- Throws:
SQLException- if parameterIndex does not correspond to a parameter marker in the SQL statement; if a database access error occurs; this method is called on a closedPreparedStatementor if the length specified is less than zero.
-
setClob
public void setClob(int parameterIndex, Reader reader) throws SQLExceptionSets the designated parameter to aReaderobject. This method differs from thesetCharacterStream (int, Reader)method because it informs the driver that the parameter value should be sent to the server as aCLOB. When thesetCharacterStreammethod is used, the driver may have to do extra work to determine whether the parameter data should be sent to the server as aLONGVARCHARor aCLOBNote: Consult your JDBC driver documentation to determine if it might be more efficient to use a version of
setClobwhich takes a length parameter.- Specified by:
setClobin interfacePreparedStatement- Parameters:
parameterIndex- index of the first parameter is 1, the second is 2, ...reader- An object that contains the data to set the parameter value to.- Throws:
SQLException- if parameterIndex does not correspond to a parameter marker in the SQL statement; if a database access error occurs; this method is called on a closedPreparedStatementor if parameterIndex does not correspond to a parameter marker in the SQL statement
-
setArray
public void setArray(int parameterIndex, Array array) throws SQLExceptionSets the designated parameter to the givenjava.sql.Arrayobject. The driver converts this to an SQLARRAYvalue when it sends it to the database.- Specified by:
setArrayin interfacePreparedStatement- Parameters:
parameterIndex- the first parameter is 1, the second is 2, ...array- anArrayobject that maps an SQLARRAYvalue- Throws:
SQLException- if parameterIndex does not correspond to a parameter marker in the SQL statement; if a database access error occurs or this method is called on a closedPreparedStatement
-
setDate
public void setDate(int parameterIndex, Date date, Calendar cal) throws SQLExceptionSets the designated parameter to the givenjava.sql.Datevalue, using the givenCalendarobject. The driver uses theCalendarobject to construct an SQLDATEvalue, which the driver then sends to the database. With aCalendarobject, the driver can calculate the date taking into account a custom timezone. If noCalendarobject is specified, the driver uses the default timezone, which is that of the virtual machine running the application.- Specified by:
setDatein interfacePreparedStatement- Parameters:
parameterIndex- the first parameter is 1, the second is 2, ...date- the parameter valuecal- theCalendarobject the driver will use to construct the date- Throws:
SQLException- if parameterIndex does not correspond to a parameter marker in the SQL statement; if a database access error occurs or this method is called on a closedPreparedStatement
-
setDate
public void setDate(int parameterIndex, Date date) throws SQLExceptionSets the designated parameter to the givenjava.sql.Datevalue using the default time zone of the virtual machine that is running the application. The driver converts this to an SQLDATEvalue when it sends it to the database.- Specified by:
setDatein interfacePreparedStatement- Parameters:
parameterIndex- the first parameter is 1, the second is 2, ...date- the parameter value- Throws:
SQLException- if parameterIndex does not correspond to a parameter marker in the SQL statement; if a database access error occurs or this method is called on a closedPreparedStatement
-
setTime
public void setTime(int parameterIndex, Time time, Calendar cal) throws SQLExceptionSets the designated parameter to the givenjava.sql.Timevalue, using the givenCalendarobject. The driver uses theCalendarobject to construct an SQLTIMEvalue, which the driver then sends to the database. With aCalendarobject, the driver can calculate the time taking into account a custom timezone. If noCalendarobject is specified, the driver uses the default timezone, which is that of the virtual machine running the application.- Specified by:
setTimein interfacePreparedStatement- Parameters:
parameterIndex- the first parameter is 1, the second is 2, ...time- the parameter valuecal- theCalendarobject the driver will use to construct the time- Throws:
SQLException- if parameterIndex does not correspond to a parameter marker in the SQL statement; if a database access error occurs or this method is called on a closedPreparedStatement
-
setTime
public void setTime(int parameterIndex, Time time) throws SQLExceptionSets the designated parameter to the givenjava.sql.Timevalue. the driver uses the default timezone, which is that of the virtual machine running the application.- Specified by:
setTimein interfacePreparedStatement- Parameters:
parameterIndex- the first parameter is 1, the second is 2, ...time- the parameter value- Throws:
SQLException- if parameterIndex does not correspond to a parameter marker in the SQL statement; if a database access error occurs or this method is called on a closedPreparedStatement
-
setTimestamp
public void setTimestamp(int parameterIndex, Timestamp timestamp, Calendar cal) throws SQLExceptionSets the designated parameter to the givenjava.sql.Timestampvalue, using the givenCalendarobject. The driver uses theCalendarobject to construct an SQLTIMESTAMPvalue, which the driver then sends to the database. With aCalendarobject, the driver can calculate the timestamp taking into account a custom timezone. If noCalendarobject is specified, the driver uses the default timezone, which is that of the virtual machine running the application.- Specified by:
setTimestampin interfacePreparedStatement- Parameters:
parameterIndex- the first parameter is 1, the second is 2, ...timestamp- the parameter valuecal- theCalendarobject the driver will use to construct the timestamp- Throws:
SQLException- if parameterIndex does not correspond to a parameter marker in the SQL statement; if a database access error occurs or this method is called on a closedPreparedStatement
-
setTimestamp
public void setTimestamp(int parameterIndex, Timestamp timestamp) throws SQLExceptionSets the designated parameter to the givenjava.sql.Timestampvalue. The driver converts this to an SQLTIMESTAMPvalue when it sends it to the database.- Specified by:
setTimestampin interfacePreparedStatement- Parameters:
parameterIndex- the first parameter is 1, the second is 2, ...timestamp- the parameter value- Throws:
SQLException- if parameterIndex does not correspond to a parameter marker in the SQL statement; if a database access error occurs or this method is called on a closedPreparedStatement
-
setNull
public void setNull(int parameterIndex, int sqlType) throws SQLExceptionSets the designated parameter to SQLNULL.Note: You must specify the parameter's SQL type.
- Specified by:
setNullin interfacePreparedStatement- Parameters:
parameterIndex- the first parameter is 1, the second is 2, ...sqlType- the SQL type code defined injava.sql.Types- Throws:
SQLException- if parameterIndex does not correspond to a parameter marker in the SQL statement; if a database access error occurs or this method is called on a closedPreparedStatement
-
setNull
public void setNull(int parameterIndex, ColumnType mariadbType) throws SQLExceptionSets the designated parameter to SQLNULL.Note: You must specify the parameter's SQL type.
- Parameters:
parameterIndex- the first parameter is 1, the second is 2, ...mariadbType- the type code defined inColumnType- Throws:
SQLException- if parameterIndex does not correspond to a parameter marker in the SQL statement; if a database access error occurs or this method is called on a closedPreparedStatement
-
setNull
public void setNull(int parameterIndex, int sqlType, String typeName) throws SQLExceptionSets the designated parameter to SQLNULL. This version of the methodsetNullshould be used for user-defined types and REF type parameters. Examples of user-defined types include: STRUCT, DISTINCT, JAVA_OBJECT, and named array types.Note: To be portable, applications must give the SQL type code and the fully-qualified SQL type name when specifying a NULL user-defined or REF parameter. In the case of a user-defined type the name is the type name of the parameter itself. For a REF parameter, the name is the type name of the referenced type. If a JDBC driver does not need the type code or type name information, it may ignore it.
Although it is intended for user-defined and Ref parameters, this method may be used to set a null parameter of any JDBC type. If the parameter does not have a user-defined or REF type, the given typeName is ignored.
- Specified by:
setNullin interfacePreparedStatement- Parameters:
parameterIndex- the first parameter is 1, the second is 2, ...sqlType- a value fromjava.sql.TypestypeName- the fully-qualified name of an SQL user-defined type; ignored if the parameter is not a user-defined type or REF- Throws:
SQLException- if parameterIndex does not correspond to a parameter marker in the SQL statement; if a database access error occurs or this method is called on a closedPreparedStatement
-
setParameter
public abstract void setParameter(int parameterIndex, ParameterHolder holder) throws SQLException- Throws:
SQLException
-
setURL
public void setURL(int parameterIndex, URL url) throws SQLExceptionSets the designated parameter to the givenjava.net.URLvalue. The driver converts this to an SQLDATALINKvalue when it sends it to the database.- Specified by:
setURLin interfacePreparedStatement- Parameters:
parameterIndex- the first parameter is 1, the second is 2, ...url- thejava.net.URLobject to be set- Throws:
SQLException- if parameterIndex does not correspond to a parameter marker in the SQL statement; if a database access error occurs or this method is called on a closedPreparedStatement
-
getParameterMetaData
public abstract ParameterMetaData getParameterMetaData() throws SQLException
Retrieves the number, types and properties of thisPreparedStatementobject's parameters.- Specified by:
getParameterMetaDatain interfacePreparedStatement- Returns:
- a
ParameterMetaDataobject that contains information about the number, types and properties for each parameter marker of thisPreparedStatementobject - Throws:
SQLException- if a database access error occurs or this method is called on a closedPreparedStatement- See Also:
ParameterMetaData
-
setRowId
public void setRowId(int parameterIndex, RowId rowid) throws SQLExceptionSets the designated parameter to the givenjava.sql.RowIdobject. The driver converts this to a SQLROWIDvalue when it sends it to the database- Specified by:
setRowIdin interfacePreparedStatement- Parameters:
parameterIndex- the first parameter is 1, the second is 2, ...rowid- the parameter value- Throws:
SQLException- if parameterIndex does not correspond to a parameter marker in the SQL statement; if a database access error occurs or this method is called on a closedPreparedStatement
-
setNString
public void setNString(int parameterIndex, String value) throws SQLExceptionSets the designated parameter to the givenStringobject. The driver converts this to a SQLNCHARorNVARCHARorLONGNVARCHARvalue (depending on the argument's size relative to the driver's limits onNVARCHARvalues) when it sends it to the database.- Specified by:
setNStringin interfacePreparedStatement- Parameters:
parameterIndex- of the first parameter is 1, the second is 2, ...value- the parameter value- Throws:
SQLException- if parameterIndex does not correspond to a parameter marker in the SQL statement; if the driver does not support national character sets; if the driver can detect that a data conversion error could occur; if a database access error occurs; or this method is called on a closedPreparedStatement
-
setNCharacterStream
public void setNCharacterStream(int parameterIndex, Reader value, long length) throws SQLExceptionSets the designated parameter to aReaderobject. TheReaderreads the data till end-of-file is reached. The driver does the necessary conversion from Java character format to the national character set in the database.- Specified by:
setNCharacterStreamin interfacePreparedStatement- Parameters:
parameterIndex- of the first parameter is 1, the second is 2, ...value- the parameter valuelength- the number of characters in the parameter data.- Throws:
SQLException- if parameterIndex does not correspond to a parameter marker in the SQL statement; if the driver does not support national character sets; if the driver can detect that a data conversion error could occur; if a database access error occurs; or this method is called on a closedPreparedStatement
-
setNCharacterStream
public void setNCharacterStream(int parameterIndex, Reader value) throws SQLExceptionSets the designated parameter to aReaderobject. TheReaderreads the data till end-of-file is reached. The driver does the necessary conversion from Java character format to the national character set in the database.Note: This stream object can either be a standard Java stream object or your own subclass that implements the standard interface.
Note: Consult your JDBC driver documentation to determine if it might be more efficient to use a version of
setNCharacterStreamwhich takes a length parameter.- Specified by:
setNCharacterStreamin interfacePreparedStatement- Parameters:
parameterIndex- of the first parameter is 1, the second is 2, ...value- the parameter value- Throws:
SQLException- if parameterIndex does not correspond to a parameter marker in the SQL statement; if the driver does not support national character sets; if the driver can detect that a data conversion error could occur; if a database access error occurs; or this method is called on a closedPreparedStatement
-
setNClob
public void setNClob(int parameterIndex, NClob value) throws SQLExceptionSets the designated parameter to ajava.sql.NClobobject. The driver converts this to a SQLNCLOBvalue when it sends it to the database.- Specified by:
setNClobin interfacePreparedStatement- Parameters:
parameterIndex- of the first parameter is 1, the second is 2, ...value- the parameter value- Throws:
SQLException- if parameterIndex does not correspond to a parameter marker in the SQL statement; if the driver does not support national character sets; if the driver can detect that a data conversion error could occur; if a database access error occurs; or this method is called on a closedPreparedStatement
-
setNClob
public void setNClob(int parameterIndex, Reader reader, long length) throws SQLExceptionSets the designated parameter to aReaderobject. The reader must contain the number of characters specified by length otherwise aSQLExceptionwill be generated when thePreparedStatementis executed. This method differs from thesetCharacterStream (int, Reader, int)method because it informs the driver that the parameter value should be sent to the server as aNCLOB. When thesetCharacterStreammethod is used, the driver may have to do extra work to determine whether the parameter data should be sent to the server as aLONGNVARCHARor aNCLOB- Specified by:
setNClobin interfacePreparedStatement- Parameters:
parameterIndex- index of the first parameter is 1, the second is 2, ...reader- An object that contains the data to set the parameter value to.length- the number of characters in the parameter data.- Throws:
SQLException- if parameterIndex does not correspond to a parameter marker in the SQL statement; if the length specified is less than zero; if the driver does not support national character sets; if the driver can detect that a data conversion error could occur; if a database access error occurs or this method is called on a closedPreparedStatement
-
setNClob
public void setNClob(int parameterIndex, Reader reader) throws SQLExceptionSets the designated parameter to aReaderobject. This method differs from thesetCharacterStream (int, Reader)method because it informs the driver that the parameter value should be sent to the server as aNCLOB. When thesetCharacterStreammethod is used, the driver may have to do extra work to determine whether the parameter data should be sent to the server as aLONGNVARCHARor aNCLOBNote: Consult your JDBC driver documentation to determine if it might be more efficient to use a version of
setNClobwhich takes a length parameter.- Specified by:
setNClobin interfacePreparedStatement- Parameters:
parameterIndex- index of the first parameter is 1, the second is 2, ...reader- An object that contains the data to set the parameter value to.- Throws:
SQLException- if parameterIndex does not correspond to a parameter marker in the SQL statement; if the driver does not support national character sets; if the driver can detect that a data conversion error could occur; if a database access error occurs or this method is called on a closedPreparedStatement
-
setSQLXML
public void setSQLXML(int parameterIndex, SQLXML xmlObject) throws SQLExceptionSets the designated parameter to the givenjava.sql.SQLXMLobject. The driver converts this to an SQLXMLvalue when it sends it to the database.- Specified by:
setSQLXMLin interfacePreparedStatement- Parameters:
parameterIndex- index of the first parameter is 1, the second is 2, ...xmlObject- aSQLXMLobject that maps an SQLXMLvalue- Throws:
SQLException- if parameterIndex does not correspond to a parameter marker in the SQL statement; if a database access error occurs; this method is called on a closedPreparedStatementor thejava.xml.transform.Result,WriterorOutputStreamhas not been closed for theSQLXMLobject
-
setObject
public void setObject(int parameterIndex, Object obj, int targetSqlType, int scaleOrLength) throws SQLExceptionSets the value of the designated parameter with the given object. The second argument must be an object type; for integral values, thejava.langequivalent objects should be used.If the second argument is an
InputStreamthen the stream must contain the number of bytes specified by scaleOrLength. If the second argument is aReaderthen the reader must contain the number of characters specified by scaleOrLength. If these conditions are not true the driver will generate aSQLExceptionwhen the prepared statement is executed.The given Java object will be converted to the given targetSqlType before being sent to the database.
If the object has a custom mapping (is of a class implementing the interface
SQLData), the JDBC driver should call the methodSQLData.writeSQLto write it to the SQL data stream. If, on the other hand, the object is of a class implementingRef,Blob,Clob,NClob,Struct,java.net.URL, orArray, the driver should pass it to the database as a value of the corresponding SQL type.Note that this method may be used to pass database-specific abstract data types.
- Specified by:
setObjectin interfacePreparedStatement- Parameters:
parameterIndex- the first parameter is 1, the second is 2, ...obj- the object containing the input parameter valuetargetSqlType- the SQL type (as defined in java.sql.Types) to be sent to the database. The scale argument may further qualify this type.scaleOrLength- forjava.sql.Types.DECIMALorjava.sql.Types.NUMERIC types, this is the number of digits after the decimal point. For Java Object typesInputStreamandReader, this is the length of the data in the stream or reader. For all other types, this value will be ignored.- Throws:
SQLException- if parameterIndex does not correspond to a parameter marker in the SQL statement; if a database access error occurs; this method is called on a closedPreparedStatementor if the Java Object specified by x is an InputStream or Reader object and the value of the scale parameter is less than zero- See Also:
Types
-
setObject
public void setObject(int parameterIndex, Object obj, int targetSqlType) throws SQLExceptionSets the value of the designated parameter with the given object. This method is like the methodsetObjectabove, except that it assumes a scale of zero.- Specified by:
setObjectin interfacePreparedStatement- Parameters:
parameterIndex- the first parameter is 1, the second is 2, ...obj- the object containing the input parameter valuetargetSqlType- the SQL type (as defined in java.sql.Types) to be sent to the database- Throws:
SQLException- if parameterIndex does not correspond to a parameter marker in the SQL statement; if a database access error occurs or this method is called on a closedPreparedStatements- See Also:
Types
-
setObject
public void setObject(int parameterIndex, Object obj) throws SQLExceptionSets the value of the designated parameter using the given object. The second parameter must be of typeObject; therefore, thejava.langequivalent objects should be used for built-in types.The JDBC specification specifies a standard mapping from Java
Objecttypes to SQL types. The given argument will be converted to the corresponding SQL type before being sent to the database.- Specified by:
setObjectin interfacePreparedStatement- Parameters:
parameterIndex- the first parameter is 1, the second is 2, ...obj- the object containing the input parameter value- Throws:
SQLException- if parameterIndex does not correspond to a parameter marker in the SQL statement; if a database access error occurs; this method is called on a closedPreparedStatementor the type of the given object is ambiguous
-
setObject
public void setObject(int parameterIndex, Object obj, SQLType targetSqlType, int scaleOrLength) throws SQLException- Specified by:
setObjectin interfacePreparedStatement- Throws:
SQLException
-
setObject
public void setObject(int parameterIndex, Object obj, SQLType targetSqlType) throws SQLException- Specified by:
setObjectin interfacePreparedStatement- Throws:
SQLException
-
setAsciiStream
public void setAsciiStream(int parameterIndex, InputStream stream, long length) throws SQLExceptionSets the designated parameter to the given input stream, which will have the specified number of bytes. When a very large ASCII value is input to aLONGVARCHARparameter, it may be more practical to send it via ajava.io.InputStream. Data will be read from the stream as needed until end-of-file is reached. The JDBC driver will do any necessary conversion from ASCII to the database char format.Note: This stream object can either be a standard Java stream object or your own subclass that implements the standard interface.
- Specified by:
setAsciiStreamin interfacePreparedStatement- Parameters:
parameterIndex- the first parameter is 1, the second is 2, ...stream- the Java input stream that contains the ASCII parameter valuelength- the number of bytes in the stream- Throws:
SQLException- if parameterIndex does not correspond to a parameter marker in the SQL statement; if a database access error occurs or this method is called on a closedPreparedStatement
-
setAsciiStream
public void setAsciiStream(int parameterIndex, InputStream stream) throws SQLExceptionThis function reads up the entire stream and stores it in memory since we need to know the length when sending it to the server use the corresponding method with a length parameter if memory is an issue
Sets the designated parameter to the given input stream. When a very large ASCII value is input to aLONGVARCHARparameter, it may be more practical to send it via ajava.io.InputStream. Data will be read from the stream as needed until end-of-file is reached. The JDBC driver will do any necessary conversion from ASCII to the database char format.Note: This stream object can either be a standard Java stream object or your own subclass that implements the standard interface.
Note: Consult your JDBC driver documentation to determine if it might be more efficient to use a version of
setAsciiStreamwhich takes a length parameter.- Specified by:
setAsciiStreamin interfacePreparedStatement- Parameters:
parameterIndex- the first parameter is 1, the second is 2, ...stream- the Java input stream that contains the ASCII parameter value- Throws:
SQLException- if parameterIndex does not correspond to a parameter marker in the SQL statement; if a database access error occurs or this method is called on a closedPreparedStatement
-
setAsciiStream
public void setAsciiStream(int parameterIndex, InputStream stream, int length) throws SQLExceptionSets the designated parameter to the given input stream, which will have the specified number of bytes. When a very large ASCII value is input to aLONGVARCHARparameter, it may be more practical to send it via ajava.io.InputStream. Data will be read from the stream as needed until end-of-file is reached. The JDBC driver will do any necessary conversion from ASCII to the database char format.Note: This stream object can either be a standard Java stream object or your own subclass that implements the standard interface.
- Specified by:
setAsciiStreamin interfacePreparedStatement- Parameters:
parameterIndex- the first parameter is 1, the second is 2, ...stream- the Java input stream that contains the ASCII parameter valuelength- the number of bytes in the stream- Throws:
SQLException- if parameterIndex does not correspond to a parameter marker in the SQL statement; if a database access error occurs or this method is called on a closedPreparedStatement
-
setBinaryStream
public void setBinaryStream(int parameterIndex, InputStream stream, long length) throws SQLExceptionSets the designated parameter to the given input stream, which will have the specified number of bytes. When a very large binary value is input to aLONGVARBINARYparameter, it may be more practical to send it via ajava.io.InputStreamobject. The data will be read from the stream as needed until end-of-file is reached.Note: This stream object can either be a standard Java stream object or your own subclass that implements the standard interface.
- Specified by:
setBinaryStreamin interfacePreparedStatement- Parameters:
parameterIndex- the first parameter is 1, the second is 2, ...stream- the java input stream which contains the binary parameter valuelength- the number of bytes in the stream- Throws:
SQLException- if parameterIndex does not correspond to a parameter marker in the SQL statement; if a database access error occurs or this method is called on a closedPreparedStatement
-
setBinaryStream
public void setBinaryStream(int parameterIndex, InputStream stream) throws SQLExceptionThis function reads up the entire stream and stores it in memory since we need to know the length when sending it to the server
Sets the designated parameter to the given input stream. When a very large binary value is input to aLONGVARBINARYparameter, it may be more practical to send it via ajava.io.InputStreamobject. The data will be read from the stream as needed until end-of-file is reached.Note: This stream object can either be a standard Java stream object or your own subclass that implements the standard interface.
Note: Consult your JDBC driver documentation to determine if it might be more efficient to use a version of
setBinaryStreamwhich takes a length parameter.- Specified by:
setBinaryStreamin interfacePreparedStatement- Parameters:
parameterIndex- the first parameter is 1, the second is 2, ...stream- the java input stream which contains the binary parameter value- Throws:
SQLException- if parameterIndex does not correspond to a parameter marker in the SQL statement; if a database access error occurs or this method is called on a closedPreparedStatement
-
setBinaryStream
public void setBinaryStream(int parameterIndex, InputStream stream, int length) throws SQLExceptionSets the designated parameter to the given input stream, which will have the specified number of bytes. When a very large binary value is input to aLONGVARBINARYparameter, it may be more practical to send it via ajava.io.InputStreamobject. The data will be read from the stream as needed until end-of-file is reached.Note: This stream object can either be a standard Java stream object or your own subclass that implements the standard interface.
- Specified by:
setBinaryStreamin interfacePreparedStatement- Parameters:
parameterIndex- the first parameter is 1, the second is 2, ...stream- the java input stream which contains the binary parameter valuelength- the number of bytes in the stream- Throws:
SQLException- if parameterIndex does not correspond to a parameter marker in the SQL statement; if a database access error occurs or this method is called on a closedPreparedStatement
-
setBoolean
public void setBoolean(int parameterIndex, boolean value) throws SQLExceptionSets the designated parameter to the given Javabooleanvalue. The driver converts this to an SQLBITorBOOLEANvalue when it sends it to the database.- Specified by:
setBooleanin interfacePreparedStatement- Parameters:
parameterIndex- the first parameter is 1, the second is 2, ...value- the parameter value- Throws:
SQLException- if parameterIndex does not correspond to a parameter marker in the SQL statement; if a database access error occurs or this method is called on a closedPreparedStatement
-
setByte
public void setByte(int parameterIndex, byte bit) throws SQLExceptionSets the designated parameter to the given Javabytevalue. The driver converts this to an SQLTINYINTvalue when it sends it to the database.- Specified by:
setBytein interfacePreparedStatement- Parameters:
parameterIndex- the first parameter is 1, the second is 2, ...bit- the parameter value- Throws:
SQLException- if parameterIndex does not correspond to a parameter marker in the SQL statement; if a database access error occurs or this method is called on a closedPreparedStatement
-
setShort
public void setShort(int parameterIndex, short value) throws SQLExceptionSets the designated parameter to the given Javashortvalue. The driver converts this to an SQLSMALLINTvalue when it sends it to the database.- Specified by:
setShortin interfacePreparedStatement- Parameters:
parameterIndex- the first parameter is 1, the second is 2, ...value- the parameter value- Throws:
SQLException- if parameterIndex does not correspond to a parameter marker in the SQL statement; if a database access error occurs or this method is called on a closedPreparedStatement
-
setString
public void setString(int parameterIndex, String str) throws SQLExceptionSet string parameter.- Specified by:
setStringin interfacePreparedStatement- Parameters:
parameterIndex- the first parameter is 1, the second is 2, ...str- String- Throws:
SQLException- if parameterIndex does not correspond to a parameter marker in the SQL statement; if a database access error occurs or this method is called on a closedPreparedStatement
-
setBytes
public void setBytes(int parameterIndex, byte[] bytes) throws SQLExceptionSets the designated parameter to the given Java array of bytes. The driver converts this to an SQLVARBINARYorLONGVARBINARY(depending on the argument's size relative to the driver's limits onVARBINARYvalues) when it sends it to the database.- Specified by:
setBytesin interfacePreparedStatement- Parameters:
parameterIndex- the first parameter is 1, the second is 2, ...bytes- the parameter value- Throws:
SQLException- if parameterIndex does not correspond to a parameter marker in the SQL statement; if a database access error occurs or this method is called on a closedPreparedStatement
-
setUnicodeStream
public void setUnicodeStream(int parameterIndex, InputStream x, int length) throws SQLExceptionDeprecated.deprecatedSets the designated parameter to the given input stream, which will have the specified number of bytes.
When a very large Unicode value is input to aLONGVARCHARparameter, it may be more practical to send it via ajava.io.InputStreamobject. The data will be read from the stream as needed until end-of-file is reached. The JDBC driver will do any necessary conversion from Unicode to the database char format.
The byte format of the Unicode stream must be a Java UTF-8, as defined in the Java Virtual Machine Specification.Note: This stream object can either be a standard Java stream object or your own subclass that implements the standard interface.
- Specified by:
setUnicodeStreamin interfacePreparedStatement- Parameters:
parameterIndex- the first parameter is 1, the second is 2, ...x- ajava.io.InputStreamobject that contains the Unicode parameter valuelength- the number of bytes in the stream- Throws:
SQLException- if parameterIndex does not correspond to a parameter marker in the SQL statement; if a database access error occurs or this method is called on a closedPreparedStatement
-
setInt
public void setInt(int column, int value) throws SQLException- Specified by:
setIntin interfacePreparedStatement- Throws:
SQLException
-
setLong
public void setLong(int parameterIndex, long value) throws SQLExceptionSets the designated parameter to the given Javalongvalue. The driver converts this to an SQLBIGINTvalue when it sends it to the database.- Specified by:
setLongin interfacePreparedStatement- Parameters:
parameterIndex- the first parameter is 1, the second is 2, ...value- the parameter value- Throws:
SQLException- if parameterIndex does not correspond to a parameter marker in the SQL statement; if a database access error occurs or this method is called on a closedPreparedStatement
-
setFloat
public void setFloat(int parameterIndex, float value) throws SQLExceptionSets the designated parameter to the given Javafloatvalue. The driver converts this to an SQLREALvalue when it sends it to the database.- Specified by:
setFloatin interfacePreparedStatement- Parameters:
parameterIndex- the first parameter is 1, the second is 2, ...value- the parameter value- Throws:
SQLException- if parameterIndex does not correspond to a parameter marker in the SQL statement; if a database access error occurs or this method is called on a closedPreparedStatement
-
setDouble
public void setDouble(int parameterIndex, double value) throws SQLExceptionSets the designated parameter to the given Javadoublevalue. The driver converts this to an SQLDOUBLEvalue when it sends it to the database.- Specified by:
setDoublein interfacePreparedStatement- Parameters:
parameterIndex- the first parameter is 1, the second is 2, ...value- the parameter value- Throws:
SQLException- if parameterIndex does not correspond to a parameter marker in the SQL statement; if a database access error occurs or this method is called on a closedPreparedStatement
-
setBigDecimal
public void setBigDecimal(int parameterIndex, BigDecimal bigDecimal) throws SQLExceptionSets the designated parameter to the givenjava.math.BigDecimalvalue. The driver converts this to an SQLNUMERICvalue when it sends it to the database.- Specified by:
setBigDecimalin interfacePreparedStatement- Parameters:
parameterIndex- the first parameter is 1, the second is 2, ...bigDecimal- the parameter value- Throws:
SQLException- if parameterIndex does not correspond to a parameter marker in the SQL statement; if a database access error occurs or this method is called on a closedPreparedStatement
-
-