public class MonetPreparedStatement extends MonetStatement implements PreparedStatement
PreparedStatement suitable for the MonetDB database.
This implementation of the PreparedStatement interface uses the
capabilities of the MonetDB/SQL backend to prepare and execute
queries. The backend takes care of finding the '?'s in the input and
returns the types it expects for them.
An example of a server response on a prepare query is:
% prepare select name from tables where id > ? and id < ?; &5 0 2 3 2 # prepare, prepare, prepare # table_name # type, digits, scale # name # varchar, int, int # type # 0, 0, 0 # length [ "int", 9, 0 ] [ "int", 9, 0 ]
closedCLOSE_ALL_RESULTS, CLOSE_CURRENT_RESULT, EXECUTE_FAILED, KEEP_CURRENT_RESULT, NO_GENERATED_KEYS, RETURN_GENERATED_KEYS, SUCCESS_NO_INFO| Modifier and Type | Method and Description |
|---|---|
void |
addBatch()
Adds a set of parameters to this PreparedStatement object's batch of commands.
|
void |
addBatch(String q)
override the addBatch from the Statement to throw an SQLException
|
void |
clearParameters()
Clears the current parameter values immediately.
|
void |
close()
Releases this PreparedStatement object's database and JDBC
resources immediately instead of waiting for this to happen when
it is automatically closed.
|
boolean |
execute()
Executes the SQL statement in this PreparedStatement object,
which may be any kind of SQL statement.
|
boolean |
execute(String q)
override the execute from the Statement to throw an SQLException
|
ResultSet |
executeQuery()
Executes the SQL query in this PreparedStatement object and returns the ResultSet object generated by the query.
|
ResultSet |
executeQuery(String q)
override the executeQuery from the Statement to throw an SQLException
|
int |
executeUpdate()
Executes the SQL statement in this PreparedStatement object, which must be an SQL INSERT, UPDATE or DELETE
statement; or an SQL statement that returns nothing, such as a DDL statement.
|
int |
executeUpdate(String q)
override the executeUpdate from the Statement to throw an SQLException
|
protected void |
finalize()
Call close to release the server-sided handle for this PreparedStatement.
|
ResultSetMetaData |
getMetaData()
Retrieves a ResultSetMetaData object that contains information
about the columns of the ResultSet object that will be returned
when this PreparedStatement object is executed.
|
ParameterMetaData |
getParameterMetaData()
Retrieves the number, types and properties of this PreparedStatement object's parameters.
|
void |
setArray(int i,
Array x)
Sets the designated parameter to the given Array object.
|
void |
setAsciiStream(int parameterIndex,
InputStream x)
Sets the designated parameter to the given input stream, which will have
the specified number of bytes.
|
void |
setAsciiStream(int parameterIndex,
InputStream x,
int length)
Sets the designated parameter to the given input stream, which will have
the specified number of bytes.
|
void |
setAsciiStream(int parameterIndex,
InputStream x,
long length)
Sets the designated parameter to the given input stream, which
will have the specified number of bytes.
|
void |
setBigDecimal(int idx,
BigDecimal x)
Sets the designated parameter to the given java.math.BigDecimal value.
|
void |
setBinaryStream(int parameterIndex,
InputStream x)
Sets the designated parameter to the given input stream, which will have
the specified number of bytes.
|
void |
setBinaryStream(int parameterIndex,
InputStream x,
int length)
Sets the designated parameter to the given input stream, which will have
the specified number of bytes.
|
void |
setBinaryStream(int parameterIndex,
InputStream x,
long length)
Sets the designated parameter to the given input stream, which will have
the specified number of bytes.
|
void |
setBlob(int parameterIndex,
Blob x)
Sets the designated parameter to the given Blob object.
|
void |
setBlob(int parameterIndex,
InputStream stream)
Sets the designated parameter to the given Blob object.
|
void |
setBlob(int parameterIndex,
InputStream stream,
long length)
Sets the designated parameter to a InputStream object.
|
void |
setBoolean(int parameterIndex,
boolean x)
Sets the designated parameter to the given Java boolean value.
|
void |
setByte(int parameterIndex,
byte x)
Sets the designated parameter to the given Java byte value.
|
void |
setBytes(int parameterIndex,
byte[] x)
Sets the designated parameter to the given Java array of bytes.
|
void |
setCharacterStream(int parameterIndex,
Reader reader)
Sets the designated parameter to the given Reader object, which is the
given number of characters long.
|
void |
setCharacterStream(int parameterIndex,
Reader reader,
int length)
Sets the designated parameter to the given Reader object, which is the
given number of characters long.
|
void |
setCharacterStream(int parameterIndex,
Reader reader,
long length)
Sets the designated parameter to the given Reader object, which is the
given number of characters long.
|
void |
setClob(int i,
Clob x)
Sets the designated parameter to the given Clob object.
|
void |
setClob(int i,
Reader reader)
Sets the designated parameter to the given Clob object.
|
void |
setClob(int i,
Reader reader,
long length)
Sets the designated parameter to a Reader object.
|
void |
setDate(int parameterIndex,
Date x)
Sets the designated parameter to the given java.sql.Date value.
|
void |
setDate(int parameterIndex,
Date x,
Calendar cal)
Sets the designated parameter to the given java.sql.Date value, using
the given Calendar object.
|
void |
setDouble(int parameterIndex,
double x)
Sets the designated parameter to the given Java double value.
|
void |
setFloat(int parameterIndex,
float x)
Sets the designated parameter to the given Java float value.
|
void |
setInt(int parameterIndex,
int x)
Sets the designated parameter to the given Java int value.
|
void |
setLong(int parameterIndex,
long x)
Sets the designated parameter to the given Java long value.
|
void |
setNCharacterStream(int i,
Reader value)
Sets the designated parameter to a Reader object.
|
void |
setNCharacterStream(int i,
Reader value,
long length)
Sets the designated parameter to a Reader object.
|
void |
setNClob(int i,
NClob value)
Sets the designated parameter to a java.sql.NClob object.
|
void |
setNClob(int i,
Reader value)
Sets the designated parameter to a java.sql.NClob object.
|
void |
setNClob(int i,
Reader r,
long length)
Sets the designated parameter to a Reader object.
|
void |
setNString(int i,
String value)
Sets the designated paramter to the given String object.
|
void |
setNull(int parameterIndex,
int sqlType)
Sets the designated parameter to SQL NULL.
|
void |
setNull(int paramIndex,
int sqlType,
String typeName)
Sets the designated parameter to SQL NULL.
|
void |
setObject(int index,
Object x)
Sets the value of the designated parameter using the given
object.
|
void |
setObject(int parameterIndex,
Object x,
int targetSqlType)
Sets the value of the designated parameter with the given object.
|
void |
setObject(int parameterIndex,
Object x,
int targetSqlType,
int scale)
Sets the value of the designated parameter with the given object.
|
void |
setRef(int i,
Ref x)
Sets the designated parameter to the given REF(
|
void |
setRowId(int i,
RowId x)
Sets the designated parameter to the given java.sql.RowId object.
|
void |
setShort(int parameterIndex,
short x)
Sets the designated parameter to the given Java short value.
|
void |
setSQLXML(int parameterIndex,
SQLXML x)
Sets the designated parameter to the given java.sql.SQLXML
object.
|
void |
setString(int parameterIndex,
String x)
Sets the designated parameter to the given Java String value.
|
void |
setTime(int index,
Time x)
Sets the designated parameter to the given java.sql.Time value.
|
void |
setTime(int index,
Time x,
Calendar cal)
Sets the designated parameter to the given java.sql.Time value,
using the given Calendar object.
|
void |
setTimestamp(int index,
Timestamp x)
Sets the designated parameter to the given java.sql.Timestamp
value.
|
void |
setTimestamp(int index,
Timestamp x,
Calendar cal)
Sets the designated parameter to the given java.sql.Timestamp
value, using the given Calendar object.
|
void |
setUnicodeStream(int parameterIndex,
InputStream x,
int length)
Deprecated.
|
void |
setURL(int parameterIndex,
URL x)
Sets the designated parameter to the given java.net.URL value.
|
cancel, clearBatch, clearWarnings, closeOnCompletion, execute, execute, execute, executeBatch, executeUpdate, executeUpdate, executeUpdate, getConnection, getFetchDirection, getFetchSize, getGeneratedKeys, getMaxFieldSize, getMaxRows, getMoreResults, getMoreResults, getQueryTimeout, getResultSet, getResultSetConcurrency, getResultSetHoldability, getResultSetType, getUpdateCount, getWarnings, isClosed, isCloseOnCompletion, isPoolable, setCursorName, setEscapeProcessing, setFetchDirection, setFetchSize, setMaxFieldSize, setMaxRows, setPoolable, setQueryTimeoutisWrapperFor, unwrapclone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitexecuteLargeUpdate, setObject, setObjectcancel, clearBatch, clearWarnings, closeOnCompletion, execute, execute, execute, executeBatch, executeLargeBatch, executeLargeUpdate, executeLargeUpdate, executeLargeUpdate, executeLargeUpdate, executeUpdate, executeUpdate, executeUpdate, getConnection, getFetchDirection, getFetchSize, getGeneratedKeys, getLargeMaxRows, getLargeUpdateCount, getMaxFieldSize, getMaxRows, getMoreResults, getMoreResults, getQueryTimeout, getResultSet, getResultSetConcurrency, getResultSetHoldability, getResultSetType, getUpdateCount, getWarnings, isClosed, isCloseOnCompletion, isPoolable, setCursorName, setEscapeProcessing, setFetchDirection, setFetchSize, setLargeMaxRows, setMaxFieldSize, setMaxRows, setPoolable, setQueryTimeoutisWrapperFor, unwrappublic void addBatch()
throws SQLException
addBatch in interface PreparedStatementSQLException - if a database access error occurspublic void addBatch(String q) throws SQLException
addBatch in interface StatementaddBatch in class MonetStatementq - typically this is a static SQL INSERT or UPDATE statementSQLException - so the PreparedStatement can throw this exceptionpublic void clearParameters()
clearParameters in interface PreparedStatementpublic boolean execute()
throws SQLException
execute in interface PreparedStatementSQLException - if a database access error occurs or an argument is supplied to this methodpublic boolean execute(String q) throws SQLException
execute in interface Statementexecute in class MonetStatementq - any SQL statementSQLException - if a database access error occurspublic ResultSet executeQuery() throws SQLException
executeQuery in interface PreparedStatementSQLException - if a database access error occurs or the SQL statement does not return a ResultSet objectpublic ResultSet executeQuery(String q) throws SQLException
executeQuery in interface StatementexecuteQuery in class MonetStatementq - an SQL statement to be sent to the database, typically a
static SQL SELECT statementSQLException - if a database access error occurs or the given SQL
statement produces anything other than a single ResultSet objectpublic int executeUpdate()
throws SQLException
executeUpdate in interface PreparedStatementSQLException - if a database access error occurs or the SQL statement returns a ResultSet objectpublic int executeUpdate(String q) throws SQLException
executeUpdate in interface StatementexecuteUpdate in class MonetStatementq - an SQL INSERT, UPDATE or DELETE statement or an SQL statement
that returns nothingSQLException - if a database access error occurs or the given SQL
statement produces a ResultSet objectpublic ResultSetMetaData getMetaData()
getMetaData in interface PreparedStatementpublic ParameterMetaData getParameterMetaData() throws SQLException
getParameterMetaData in interface PreparedStatementSQLException - if a database access error occurspublic void setArray(int i,
Array x)
throws SQLException
setArray in interface PreparedStatementi - the first parameter is 1, the second is 2, ...x - an Array object that maps an SQL ARRAY valueSQLException - if a database access error occurspublic void setAsciiStream(int parameterIndex,
InputStream x)
throws SQLException
setAsciiStream in interface PreparedStatementparameterIndex - the first parameter is 1, the second is 2, ...x - the Java input stream that contains the ASCII parameter valueSQLException - if a database access error occursSQLFeatureNotSupportedException - the JDBC driver does
not support this methodpublic void setAsciiStream(int parameterIndex,
InputStream x,
int length)
throws SQLException
setAsciiStream in interface PreparedStatementparameterIndex - the first parameter is 1, the second is 2, ...x - the Java input stream that contains the ASCII parameter valuelength - the number of bytes in the streamSQLException - if a database access error occurspublic void setAsciiStream(int parameterIndex,
InputStream x,
long length)
throws SQLException
setAsciiStream in interface PreparedStatementparameterIndex - the first parameter is 1, the second is 2, ...x - the Java input stream that contains the ASCII parameter valuelength - the number of bytes in the streamSQLException - if a database access error occursSQLFeatureNotSupportedException - the JDBC driver does
not support this methodpublic void setBigDecimal(int idx,
BigDecimal x)
throws SQLException
setBigDecimal in interface PreparedStatementidx - the first parameter is 1, the second is 2, ...x - the parameter valueSQLException - if a database access error occurspublic void setBinaryStream(int parameterIndex,
InputStream x)
throws SQLException
setBinaryStream in interface PreparedStatementparameterIndex - the first parameter is 1, the second is 2, ...x - the java input stream which contains the binary parameter valueSQLException - if a database access error occursSQLFeatureNotSupportedException - the JDBC driver does
not support this methodpublic void setBinaryStream(int parameterIndex,
InputStream x,
int length)
throws SQLException
setBinaryStream in interface PreparedStatementparameterIndex - the first parameter is 1, the second is 2, ...x - the java input stream which contains the binary parameter valuelength - the number of bytes in the streamSQLException - if a database access error occursSQLFeatureNotSupportedException - the JDBC driver does
not support this methodpublic void setBinaryStream(int parameterIndex,
InputStream x,
long length)
throws SQLException
setBinaryStream in interface PreparedStatementparameterIndex - the first parameter is 1, the second is 2, ...x - the java input stream which contains the binary parameter valuelength - the number of bytes in the streamSQLException - if a database access error occursSQLFeatureNotSupportedException - the JDBC driver does
not support this methodpublic void setBlob(int parameterIndex,
InputStream stream)
throws SQLException
setBlob in interface PreparedStatementparameterIndex - the first parameter is 1, the second is 2, ...stream - an object that contains the data to set the parameter value toSQLException - if a database access error occurspublic void setBlob(int parameterIndex,
Blob x)
throws SQLException
setBlob in interface PreparedStatementparameterIndex - the first parameter is 1, the second is 2, ...x - a Blob object that maps an SQL BLOB valueSQLException - if a database access error occurspublic void setBlob(int parameterIndex,
InputStream stream,
long length)
throws SQLException
setBlob in interface PreparedStatementparameterIndex - the first parameter is 1, the second is 2, ...stream - an object that contains the data to set the parameter value tolength - the number of bytes in the parameter dataSQLException - if a database access error occurspublic void setBoolean(int parameterIndex,
boolean x)
throws SQLException
setBoolean in interface PreparedStatementparameterIndex - the first parameter is 1, the second is 2, ...x - the parameter valueSQLException - if a database access error occurspublic void setByte(int parameterIndex,
byte x)
throws SQLException
setByte in interface PreparedStatementparameterIndex - the first parameter is 1, the second is 2, ...x - the parameter valueSQLException - if a database access error occurspublic void setBytes(int parameterIndex,
byte[] x)
throws SQLException
setBytes in interface PreparedStatementparameterIndex - the first parameter is 1, the second is 2, ...x - the parameter valueSQLException - if a database access error occurspublic void setCharacterStream(int parameterIndex,
Reader reader,
int length)
throws SQLException
setCharacterStream in interface PreparedStatementparameterIndex - the first parameter is 1, the second is 2, ...reader - the java.io.Reader object that contains the Unicode datalength - the number of characters in the streamSQLException - if a database access error occurspublic void setCharacterStream(int parameterIndex,
Reader reader)
throws SQLException
setCharacterStream in interface PreparedStatementparameterIndex - the first parameter is 1, the second is 2, ...reader - the java.io.Reader object that contains the Unicode dataSQLException - if a database access error occurspublic void setCharacterStream(int parameterIndex,
Reader reader,
long length)
throws SQLException
setCharacterStream in interface PreparedStatementparameterIndex - the first parameter is 1, the second is 2, ...reader - the java.io.Reader object that contains the Unicode datalength - the number of characters in the streamSQLException - if a database access error occurspublic void setClob(int i,
Clob x)
throws SQLException
setClob in interface PreparedStatementi - the first parameter is 1, the second is 2, ...x - a Clob object that maps an SQL CLOB valueSQLException - if a database access error occurspublic void setClob(int i,
Reader reader)
throws SQLException
setClob in interface PreparedStatementi - the first parameter is 1, the second is 2, ...reader - an object that contains the data to set the parameter
value toSQLException - if a database access error occurspublic void setClob(int i,
Reader reader,
long length)
throws SQLException
setClob in interface PreparedStatementi - 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.SQLException - if a database access error occurspublic void setDate(int parameterIndex,
Date x)
throws SQLException
setDate in interface PreparedStatementparameterIndex - the first parameter is 1, the second is 2, ...x - the parameter valueSQLException - if a database access error occurspublic void setDate(int parameterIndex,
Date x,
Calendar cal)
throws SQLException
setDate in interface PreparedStatementparameterIndex - the first parameter is 1, the second is 2, ...x - the parameter valuecal - the Calendar object the driver will use to construct the dateSQLException - if a database access error occurspublic void setDouble(int parameterIndex,
double x)
throws SQLException
setDouble in interface PreparedStatementparameterIndex - the first parameter is 1, the second is 2, ...x - the parameter valueSQLException - if a database access error occurspublic void setFloat(int parameterIndex,
float x)
throws SQLException
setFloat in interface PreparedStatementparameterIndex - the first parameter is 1, the second is 2, ...x - the parameter valueSQLException - if a database access error occurspublic void setInt(int parameterIndex,
int x)
throws SQLException
setInt in interface PreparedStatementparameterIndex - the first parameter is 1, the second is 2, ...x - the parameter valueSQLException - if a database access error occurspublic void setLong(int parameterIndex,
long x)
throws SQLException
setLong in interface PreparedStatementparameterIndex - the first parameter is 1, the second is 2, ...x - the parameter valueSQLException - if a database access error occurspublic void setNCharacterStream(int i,
Reader value)
throws SQLException
setNCharacterStream in interface PreparedStatementi - the first parameter is 1, the second is 2, ...value - the parameter valueSQLException - if a database access error occursSQLFeatureNotSupportedException - the JDBC driver does
not support this methodpublic void setNCharacterStream(int i,
Reader value,
long length)
throws SQLException
setNCharacterStream in interface PreparedStatementi - the first parameter is 1, the second is 2, ...value - the parameter valuelength - the number of characters in the parameter data.SQLException - if a database access error occursSQLFeatureNotSupportedException - the JDBC driver does
not support this methodpublic void setNClob(int i,
Reader value)
throws SQLException
setNClob in interface PreparedStatementi - the first parameter is 1, the second is 2, ...value - the parameter valueSQLException - if a database access error occursSQLFeatureNotSupportedException - the JDBC driver does
not support this methodpublic void setNClob(int i,
NClob value)
throws SQLException
setNClob in interface PreparedStatementi - the first parameter is 1, the second is 2, ...value - the parameter valueSQLException - if a database access error occursSQLFeatureNotSupportedException - the JDBC driver does
not support this methodpublic void setNClob(int i,
Reader r,
long length)
throws SQLException
setNClob in interface PreparedStatementi - the first parameter is 1, the second is 2, ...r - An object that contains the data to set the parameter
value tolength - the number of characters in the parameter dataSQLException - if a database access error occursSQLFeatureNotSupportedException - the JDBC driver does
not support this methodpublic void setNString(int i,
String value)
throws SQLException
setNString in interface PreparedStatementi - the first parameter is 1, the second is 2, ...value - the parameter valueSQLException - if a database access error occursSQLFeatureNotSupportedException - the JDBC driver does
not support this methodpublic void setNull(int parameterIndex,
int sqlType)
throws SQLException
setNull in interface PreparedStatementparameterIndex - the first parameter is 1, the second is 2, ...sqlType - the SQL type code defined in java.sql.TypesSQLException - if a database access error occurspublic void setNull(int paramIndex,
int sqlType,
String typeName)
throws SQLException
setNull in interface PreparedStatementparamIndex - the first parameter is 1, the second is 2, ...sqlType - a value from java.sql.TypestypeName - the fully-qualified name of an SQL user-defined type;
ignored if the parameter is not a user-defined type or
REFSQLException - if a database access error occurspublic void setObject(int index,
Object x)
throws SQLException
setObject in interface PreparedStatementindex - the first parameter is 1, the second is 2, ...x - the object containing the input parameter valueSQLException - if a database access error occurs or the type of
the given object is ambiguouspublic void setObject(int parameterIndex,
Object x,
int targetSqlType)
throws SQLException
setObject in interface PreparedStatementparameterIndex - the first parameter is 1, the second is 2, ...x - the object containing the input parameter valuetargetSqlType - the SQL type (as defined in java.sql.Types) to be
sent to the databaseSQLException - if a database access error occurspublic void setObject(int parameterIndex,
Object x,
int targetSqlType,
int scale)
throws SQLException
setObject in interface PreparedStatementparameterIndex - the first parameter is 1, the second is 2, ...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.scale - for java.sql.Types.DECIMAL or java.sql.Types.NUMERIC types,
this is the number of digits after the decimal
point. For Java Object types InputStream and Reader,
this is the length of the data in the stream or
reader. For all other types, this value will be
ignored.SQLException - if a database access error occursTypespublic void setRef(int i,
Ref x)
throws SQLException
setRef in interface PreparedStatementi - the first parameter is 1, the second is 2, ...x - an SQL REF valueSQLException - if a database access error occursSQLFeatureNotSupportedException - the JDBC driver does
not support this methodpublic void setRowId(int i,
RowId x)
throws SQLException
setRowId in interface PreparedStatementi - the first parameter is 1, the second is 2, ...x - the parameter valueSQLException - if a database access error occursSQLFeatureNotSupportedException - the JDBC driver does
not support this methodpublic void setShort(int parameterIndex,
short x)
throws SQLException
setShort in interface PreparedStatementparameterIndex - the first parameter is 1, the second is 2, ...x - the parameter valueSQLException - if a database access error occurspublic void setString(int parameterIndex,
String x)
throws SQLException
setString in interface PreparedStatementparameterIndex - the first parameter is 1, the second is 2, ...x - the parameter valueSQLException - if a database access error occurspublic void setSQLXML(int parameterIndex,
SQLXML x)
throws SQLException
setSQLXML in interface PreparedStatementparameterIndex - the first parameter is 1, the second is 2, ...x - a SQLXML object that maps an SQL XML valueSQLException - if a database access error occursSQLFeatureNotSupportedException - the JDBC driver does
not support this methodpublic void setTime(int index,
Time x)
throws SQLException
setTime in interface PreparedStatementindex - the first parameter is 1, the second is 2, ...x - the parameter valueSQLException - if a database access error occurspublic void setTime(int index,
Time x,
Calendar cal)
throws SQLException
setTime in interface PreparedStatementindex - the first parameter is 1, the second is 2, ...x - the parameter valuecal - the Calendar object the driver will use to construct the timeSQLException - if a database access error occurspublic void setTimestamp(int index,
Timestamp x)
throws SQLException
setTimestamp in interface PreparedStatementindex - the first parameter is 1, the second is 2, ...x - the parameter valueSQLException - if a database access error occurspublic void setTimestamp(int index,
Timestamp x,
Calendar cal)
throws SQLException
setTimestamp in interface PreparedStatementindex - the first parameter is 1, the second is 2, ...x - the parameter valuecal - the Calendar object the driver will use to construct the
timestampSQLException - if a database access error occurs@Deprecated public void setUnicodeStream(int parameterIndex, InputStream x, int length) throws SQLException
setUnicodeStream in interface PreparedStatementparameterIndex - the first parameter is 1, the second is 2, ...x - a java.io.InputStream object that contains the Unicode
parameter value as two-byte Unicode characterslength - the number of bytes in the streamSQLException - if a database access error occurspublic void setURL(int parameterIndex,
URL x)
throws SQLException
setURL in interface PreparedStatementparameterIndex - the first parameter is 1, the second is 2, ...x - the java.net.URL object to be setSQLException - if a database access error occurspublic void close()
close in interface AutoCloseableclose in interface Statementclose in class MonetStatementCopyright © 2017. All rights reserved.