Class ParamBuilder
PreparedStatement and allows to set the values with a builder pattern.
The index of the argument will be moved automatically
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionSets the designated parameter to the givenjava.sql.Arrayobject.Sets the designated parameter to the given input stream.setAsciiStream(InputStream x, int length) Sets the designated parameter to the given input stream, which will have the specified number of bytes.setAsciiStream(InputStream x, long length) Sets the designated parameter to the given input stream, which will have the specified number of bytes.Sets the designated parameter to the givenjava.math.BigDecimalvalue.Sets the designated parameter to the given input stream.setBinaryStream(InputStream x, int length) Sets the designated parameter to the given input stream, which will have the specified number of bytes.setBinaryStream(InputStream x, long length) Sets the designated parameter to the given input stream, which will have the specified number of bytes.setBlob(InputStream inputStream) Sets the designated parameter to aInputStreamobject.setBlob(InputStream inputStream, long length) Sets the designated parameter to aInputStreamobject.Sets the designated parameter to the givenjava.sql.Blobobject.Sets the designated parameter to the given Javabooleanvalue.Sets the designated parameter to the given Javabytevalue.setBytes(byte[] x) Sets the designated parameter to the given Java array of bytes.setCharacterStream(Reader reader) Sets the designated parameter to the givenReaderobject.setCharacterStream(Reader reader, int length) Sets the designated parameter to the givenReaderobject, which is the given number of characters long.setCharacterStream(Reader reader, long length) Sets the designated parameter to the givenReaderobject, which is the given number of characters long.Sets the designated parameter to aReaderobject.Sets the designated parameter to aReaderobject.Sets the designated parameter to the givenjava.sql.Clobobject.Sets the designated parameter to the givenjava.sql.Datevalue using the default time zone of the virtual machine that is running the application.Sets the designated parameter to the given Javadoublevalue.Sets the designated parameter to the given Javafloatvalue.Sets the designated parameter to the given Javaintvalue.Sets the designated parameter to the given Javalongvalue.setNCharacterStream(Reader value) Sets the designated parameter to aReaderobject.setNCharacterStream(Reader value, long length) Sets the designated parameter to aReaderobject.Sets the designated parameter to aReaderobject.Sets the designated parameter to aReaderobject.Sets the designated parameter to ajava.sql.NClobobject.setNString(String value) Sets the designated parameter to the givenStringobject.setNull(int sqlType) Sets the designated parameter to SQLNULL.Sets the value of the designated parameter using the given object.Sets the value of the designated parameter with the given object.Sets the value of the designated parameter with the given object.Sets the value of the designated parameter with the given object.Sets the designated parameter to the givenREF(<structured-type>)value.Sets the designated parameter to the givenjava.sql.RowIdobject.Sets the designated parameter to the given Javashortvalue.Sets the designated parameter to the givenjava.sql.SQLXMLobject.Sets the designated parameter to the given JavaStringvalue.Sets the designated parameter to the givenjava.sql.Timevalue.Sets the designated parameter to the givenjava.sql.Timestampvalue.Sets the designated parameter to the givenjava.net.URLvalue.
-
Constructor Details
-
ParamBuilder
Create a new ParamBuilder- Parameters:
stmt- statement to wrap
-
-
Method Details
-
setNull
Sets the designated parameter to SQLNULL.Note: You must specify the parameter's SQL type.
- Parameters:
sqlType- the SQL type code defined injava.sql.Types- Returns:
- ParamBuilder with values 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 closedPreparedStatementSQLFeatureNotSupportedException- ifsqlTypeis aARRAY,BLOB,CLOB,DATALINK,JAVA_OBJECT,NCHAR,NCLOB,NVARCHAR,LONGNVARCHAR,REF,ROWID,SQLXMLorSTRUCTdata type and the JDBC driver does not support this data type
-
setBoolean
Sets the designated parameter to the given Javabooleanvalue. The driver converts this to an SQLBITorBOOLEANvalue when it sends it to the database.- Parameters:
x- the parameter value- Returns:
- ParamBuilder with values 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
-
setByte
Sets the designated parameter to the given Javabytevalue. The driver converts this to an SQLTINYINTvalue when it sends it to the database.- Parameters:
x- the parameter value- Returns:
- ParamBuilder with values 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
-
setShort
Sets the designated parameter to the given Javashortvalue. The driver converts this to an SQLSMALLINTvalue when it sends it to the database.- Parameters:
x- the parameter value- Returns:
- ParamBuilder with values 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
-
setInt
Sets the designated parameter to the given Javaintvalue. The driver converts this to an SQLINTEGERvalue when it sends it to the database.- Parameters:
x- the parameter value- Returns:
- ParamBuilder with values 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
-
setLong
Sets the designated parameter to the given Javalongvalue. The driver converts this to an SQLBIGINTvalue when it sends it to the database.- Parameters:
x- the parameter value- Returns:
- ParamBuilder with values 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
-
setFloat
Sets the designated parameter to the given Javafloatvalue. The driver converts this to an SQLREALvalue when it sends it to the database.- Parameters:
x- the parameter value- Returns:
- ParamBuilder with values 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
-
setDouble
Sets the designated parameter to the given Javadoublevalue. The driver converts this to an SQLDOUBLEvalue when it sends it to the database.- Parameters:
x- the parameter value- Returns:
- ParamBuilder with values 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
-
setBigDecimal
Sets the designated parameter to the givenjava.math.BigDecimalvalue. The driver converts this to an SQLNUMERICvalue when it sends it to the database.- Parameters:
x- the parameter value- Returns:
- ParamBuilder with values 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
-
setString
Sets the designated parameter to the given JavaStringvalue. The driver converts this to an SQLVARCHARorLONGVARCHARvalue (depending on the argument's size relative to the driver's limits onVARCHARvalues) when it sends it to the database.- Parameters:
x- the parameter value- Returns:
- ParamBuilder with values 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
-
setBytes
Sets 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.- Parameters:
x- the parameter value- Returns:
- ParamBuilder with values 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
-
setDate
Sets 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.- Parameters:
x- the parameter value- Returns:
- ParamBuilder with values 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
-
setTime
Sets the designated parameter to the givenjava.sql.Timevalue. The driver converts this to an SQLTIMEvalue when it sends it to the database.- Parameters:
x- the parameter value- Returns:
- ParamBuilder with values 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
-
setTimestamp
Sets the designated parameter to the givenjava.sql.Timestampvalue. The driver converts this to an SQLTIMESTAMPvalue when it sends it to the database.- Parameters:
x- the parameter value- Returns:
- ParamBuilder with values 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
-
setAsciiStream
Sets 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.
- Parameters:
x- the Java input stream that contains the ASCII parameter valuelength- the number of bytes in the stream- Returns:
- ParamBuilder with values 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
-
setBinaryStream
Sets 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.
- Parameters:
x- the java input stream which contains the binary parameter valuelength- the number of bytes in the stream- Returns:
- ParamBuilder with values 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
-
setObject
Sets the value of the designated parameter with the given object.This method is similar to
setObject(Object x, int targetSqlType, int scaleOrLength), except that it assumes a scale of zero.- Parameters:
x- the object containing the input parameter valuetargetSqlType- the SQL type (as defined in java.sql.Types) to be sent to the database- Returns:
- ParamBuilder with values 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 closed PreparedStatementSQLFeatureNotSupportedException- if the JDBC driver does not support the specified targetSqlType- See Also:
-
setObject
Sets the value of the designated parameter using the given object.
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.Note that this method may be used to pass database- specific abstract data types, by using a driver-specific Java type.
If the object 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,RowId,SQLXMLorArray, the driver should pass it to the database as a value of the corresponding SQL type.Note: Not all databases allow for a non-typed Null to be sent to the backend. For maximum portability, the
setNullor thesetObject(Object x, int sqlType)method should be used instead ofsetObject(Object x).Note: This method throws an exception if there is an ambiguity, for example, if the object is of a class implementing more than one of the interfaces named above.
- Parameters:
x- the object containing the input parameter value- Returns:
- ParamBuilder with values set.
- 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
-
setCharacterStream
Sets 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.
- Parameters:
reader- thejava.io.Readerobject that contains the Unicode datalength- the number of characters in the stream- Returns:
- ParamBuilder with values 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- Since:
- 1.2
-
setRef
Sets the designated parameter to the givenREF(<structured-type>)value. The driver converts this to an SQLREFvalue when it sends it to the database.- Parameters:
x- an SQLREFvalue- Returns:
- ParamBuilder with values 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 closedPreparedStatementSQLFeatureNotSupportedException- if the JDBC driver does not support this method- Since:
- 1.2
-
setBlob
Sets the designated parameter to the givenjava.sql.Blobobject. The driver converts this to an SQLBLOBvalue when it sends it to the database.- Parameters:
x- aBlobobject that maps an SQLBLOBvalue- Returns:
- ParamBuilder with values 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 closedPreparedStatementSQLFeatureNotSupportedException- if the JDBC driver does not support this method- Since:
- 1.2
-
setClob
Sets the designated parameter to the givenjava.sql.Clobobject. The driver converts this to an SQLCLOBvalue when it sends it to the database.- Parameters:
x- aClobobject that maps an SQLCLOBvalue- Returns:
- ParamBuilder with values 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 closedPreparedStatementSQLFeatureNotSupportedException- if the JDBC driver does not support this method- Since:
- 1.2
-
setArray
Sets the designated parameter to the givenjava.sql.Arrayobject. The driver converts this to an SQLARRAYvalue when it sends it to the database.- Parameters:
x- anArrayobject that maps an SQLARRAYvalue- Returns:
- ParamBuilder with values 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 closedPreparedStatementSQLFeatureNotSupportedException- if the JDBC driver does not support this method- Since:
- 1.2
-
setURL
Sets the designated parameter to the givenjava.net.URLvalue. The driver converts this to an SQLDATALINKvalue when it sends it to the database.- Parameters:
x- thejava.net.URLobject to be set- Returns:
- ParamBuilder with values 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 closedPreparedStatementSQLFeatureNotSupportedException- if the JDBC driver does not support this method- Since:
- 1.4
-
setRowId
Sets the designated parameter to the givenjava.sql.RowIdobject. The driver converts this to a SQLROWIDvalue when it sends it to the database- Parameters:
x- the parameter value- Returns:
- ParamBuilder with values 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 closedPreparedStatementSQLFeatureNotSupportedException- if the JDBC driver does not support this method- Since:
- 1.6
-
setNString
Sets 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.- Parameters:
value- the parameter value- Returns:
- ParamBuilder with values set.
- 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 closedPreparedStatementSQLFeatureNotSupportedException- if the JDBC driver does not support this method- Since:
- 1.6
-
setNCharacterStream
Sets 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.- Parameters:
value- the parameter valuelength- the number of characters in the parameter data.- Returns:
- ParamBuilder with values set.
- 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 closedPreparedStatementSQLFeatureNotSupportedException- if the JDBC driver does not support this method- Since:
- 1.6
-
setNClob
Sets the designated parameter to ajava.sql.NClobobject. The driver converts this to a SQLNCLOBvalue when it sends it to the database.- Parameters:
value- the parameter value- Returns:
- ParamBuilder with values set.
- 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 closedPreparedStatementSQLFeatureNotSupportedException- if the JDBC driver does not support this method- Since:
- 1.6
-
setClob
Sets 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- Parameters:
reader- An object that contains the data to set the parameter value to.length- the number of characters in the parameter data.- Returns:
- ParamBuilder with values set.
- 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.SQLFeatureNotSupportedException- if the JDBC driver does not support this method- Since:
- 1.6
-
setBlob
Sets the designated parameter to aInputStreamobject. TheInputstreammust 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- Parameters:
inputStream- An object that contains the data to set the parameter value to.length- the number of bytes in the parameter data.- Returns:
- ParamBuilder with values set.
- 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 theInputStreamdoes not match the specified length.SQLFeatureNotSupportedException- if the JDBC driver does not support this method- Since:
- 1.6
-
setNClob
Sets 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- Parameters:
reader- An object that contains the data to set the parameter value to.length- the number of characters in the parameter data.- Returns:
- ParamBuilder with values set.
- 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 closedPreparedStatementSQLFeatureNotSupportedException- if the JDBC driver does not support this method- Since:
- 1.6
-
setSQLXML
Sets the designated parameter to the givenjava.sql.SQLXMLobject. The driver converts this to an SQLXMLvalue when it sends it to the database.- Parameters:
xmlObject- aSQLXMLobject that maps an SQLXMLvalue- Returns:
- ParamBuilder with values set.
- 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 theSQLXMLobjectSQLFeatureNotSupportedException- if the JDBC driver does not support this method- Since:
- 1.6
-
setObject
Sets the value of the designated parameter with the given object.
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.
- Parameters:
x- 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.- Returns:
- ParamBuilder with values set.
- 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 zeroSQLFeatureNotSupportedException- if the JDBC driver does not support the specified targetSqlType- See Also:
-
setAsciiStream
Sets 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.
- Parameters:
x- the Java input stream that contains the ASCII parameter valuelength- the number of bytes in the stream- Returns:
- ParamBuilder with values 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- Since:
- 1.6
-
setBinaryStream
Sets 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.
- Parameters:
x- the java input stream which contains the binary parameter valuelength- the number of bytes in the stream- Returns:
- ParamBuilder with values 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- Since:
- 1.6
-
setCharacterStream
Sets 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.
- Parameters:
reader- thejava.io.Readerobject that contains the Unicode datalength- the number of characters in the stream- Returns:
- ParamBuilder with values 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- Since:
- 1.6
-
setAsciiStream
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.- Parameters:
x- the Java input stream that contains the ASCII parameter value- Returns:
- ParamBuilder with values 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 closedPreparedStatementSQLFeatureNotSupportedException- if the JDBC driver does not support this method- Since:
- 1.6
-
setBinaryStream
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.- Parameters:
x- the java input stream which contains the binary parameter value- Returns:
- ParamBuilder with values 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 closedPreparedStatementSQLFeatureNotSupportedException- if the JDBC driver does not support this method- Since:
- 1.6
-
setCharacterStream
Sets 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.- Parameters:
reader- thejava.io.Readerobject that contains the Unicode data- Returns:
- ParamBuilder with values 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 closedPreparedStatementSQLFeatureNotSupportedException- if the JDBC driver does not support this method- Since:
- 1.6
-
setNCharacterStream
Sets 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.- Parameters:
value- the parameter value- Returns:
- ParamBuilder with values set.
- 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 closedPreparedStatementSQLFeatureNotSupportedException- if the JDBC driver does not support this method- Since:
- 1.6
-
setClob
Sets 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.- Parameters:
reader- An object that contains the data to set the parameter value to.- Returns:
- ParamBuilder with values set.
- 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 statementSQLFeatureNotSupportedException- if the JDBC driver does not support this method- Since:
- 1.6
-
setBlob
Sets 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.- Parameters:
inputStream- An object that contains the data to set the parameter value to.- Returns:
- ParamBuilder with values set.
- 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,SQLFeatureNotSupportedException- if the JDBC driver does not support this method- Since:
- 1.6
-
setNClob
Sets 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.- Parameters:
reader- An object that contains the data to set the parameter value to.- Returns:
- ParamBuilder with values set.
- 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 closedPreparedStatementSQLFeatureNotSupportedException- if the JDBC driver does not support this method- Since:
- 1.6
-
setObject
Sets the value of the designated parameter with the given object.This method is similar to
setObject(Object, int, int), except that it assumes a scale of zero.The default implementation will throw
SQLFeatureNotSupportedException- Parameters:
x- the object containing the input parameter valuetargetSqlType- the SQL type to be sent to the database- Returns:
- ParamBuilder with values 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 closedPreparedStatementSQLFeatureNotSupportedException- if the JDBC driver does not support the specified targetSqlType- Since:
- 1.8
- See Also:
-