- java.lang.Object
-
- org.postgresql.pljava.jdbc.SPIStatement
-
- org.postgresql.pljava.jdbc.SPIPreparedStatement
-
- All Implemented Interfaces:
AutoCloseable
,PreparedStatement
,Statement
,Wrapper
,SPIReadOnlyControl
public class SPIPreparedStatement extends SPIStatement implements PreparedStatement
Implementation ofPreparedStatement
for the SPI connection.- Author:
- Thomas Hallgren
-
-
Field Summary
-
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 SPIPreparedStatement(SPIConnection conn, String statement, int paramCount)
-
Method Summary
Modifier and Type Method Description void
addBatch()
void
addBatch(String statement)
The prepared statement cannot have other statements added too it.void
clearParameters()
void
close()
boolean
execute()
boolean
execute(String statement)
The prepared statement cannot be used for executing oter statements.protected long
executeBatchEntry(Object batchEntry)
ResultSet
executeQuery()
int
executeUpdate()
ResultSetMetaData
getMetaData()
ResultSetMetaData is not yet supported.ParameterMetaData
getParameterMetaData()
Due to the design of theSPI_prepare
, it is currently impossible to obtain the correct parameter meta data before all the parameters have been set, hence a ParameterMetaData obtained prior to setting the paramteres will have all parameters set to the default typeTypes.VARCHAR
.void
setArray(int columnIndex, Array value)
void
setAsciiStream(int parameterIndex, InputStream x)
void
setAsciiStream(int columnIndex, InputStream value, int length)
void
setAsciiStream(int parameterIndex, InputStream x, long length)
void
setBigDecimal(int columnIndex, BigDecimal value)
void
setBinaryStream(int parameterIndex, InputStream x)
void
setBinaryStream(int columnIndex, InputStream value, int length)
void
setBinaryStream(int parameterIndex, InputStream x, long length)
void
setBlob(int parameterIndex, InputStream inputStream)
void
setBlob(int parameterIndex, InputStream inputStream, long length)
void
setBlob(int columnIndex, Blob value)
void
setBoolean(int columnIndex, boolean value)
void
setByte(int columnIndex, byte value)
void
setBytes(int columnIndex, byte[] value)
void
setCharacterStream(int parameterIndex, Reader reader)
void
setCharacterStream(int columnIndex, Reader value, int length)
void
setCharacterStream(int parameterIndex, Reader reader, long length)
void
setClob(int parameterIndex, Reader reader)
void
setClob(int parameterIndex, Reader reader, long length)
void
setClob(int columnIndex, Clob value)
void
setDate(int columnIndex, Date value)
void
setDate(int columnIndex, Date value, Calendar cal)
void
setDouble(int columnIndex, double value)
void
setFloat(int columnIndex, float value)
void
setInt(int columnIndex, int value)
void
setLong(int columnIndex, long value)
void
setNCharacterStream(int parameterIndex, Reader value)
void
setNCharacterStream(int parameterIndex, Reader value, long length)
void
setNClob(int parameterIndex, Reader reader)
void
setNClob(int parameterIndex, Reader reader, long length)
void
setNClob(int parameterIndex, NClob value)
void
setNString(int parameterIndex, String value)
void
setNull(int columnIndex, int sqlType)
void
setNull(int columnIndex, int sqlType, String typeName)
This method can (and is the only method that can, until JDBC 4.2 SQLType is implemented) assign a specific PostgreSQL type, by name, to a PreparedStatement parameter.void
setObject(int columnIndex, Object value)
void
setObject(int columnIndex, Object value, int sqlType)
void
setObject(int columnIndex, Object value, int sqlType, int scale)
Implemented onsetObject(int,Object,int)
, discarding scale.void
setRef(int columnIndex, Ref value)
void
setRowId(int parameterIndex, RowId x)
void
setShort(int columnIndex, short value)
void
setSQLXML(int parameterIndex, SQLXML xmlObject)
void
setString(int columnIndex, String value)
void
setTime(int columnIndex, Time value)
void
setTime(int columnIndex, Time value, Calendar cal)
void
setTimestamp(int columnIndex, Timestamp value)
void
setTimestamp(int columnIndex, Timestamp value, Calendar cal)
void
setUnicodeStream(int columnIndex, InputStream value, int arg2)
void
setURL(int columnIndex, URL value)
String
toString()
-
Methods inherited from class org.postgresql.pljava.jdbc.SPIStatement
cancel, clearBatch, clearReadOnly, clearWarnings, closeOnCompletion, defaultReadOnly, execute, execute, execute, executeBatch, executeLargeBatch, executePlan, executeQuery, executeUpdate, executeUpdate, executeUpdate, executeUpdate, forceReadOnly, getConnection, getFetchDirection, getFetchSize, getGeneratedKeys, getLargeUpdateCount, getMaxFieldSize, getMaxRows, getMoreResults, getMoreResults, getQueryTimeout, getResultSet, getResultSetConcurrency, getResultSetHoldability, getResultSetType, getUpdateCount, getWarnings, internalAddBatch, isClosed, isCloseOnCompletion, isPoolable, isWrapperFor, setCursorName, setEscapeProcessing, setFetchDirection, setFetchSize, setMaxFieldSize, setMaxRows, setPoolable, setQueryTimeout, unwrap
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.sql.PreparedStatement
executeLargeUpdate, setObject, setObject
-
Methods inherited from interface java.sql.Statement
cancel, clearBatch, clearWarnings, closeOnCompletion, enquoteIdentifier, enquoteLiteral, enquoteNCharLiteral, 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
-
-
-
-
Constructor Detail
-
SPIPreparedStatement
public SPIPreparedStatement(SPIConnection conn, String statement, int paramCount)
-
-
Method Detail
-
close
public void close() throws SQLException
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceStatement
- Overrides:
close
in classSPIStatement
- Throws:
SQLException
-
executeQuery
public ResultSet executeQuery() throws SQLException
- Specified by:
executeQuery
in interfacePreparedStatement
- Throws:
SQLException
-
executeUpdate
public int executeUpdate() throws SQLException
- Specified by:
executeUpdate
in interfacePreparedStatement
- Throws:
SQLException
-
setNull
public void setNull(int columnIndex, int sqlType) throws SQLException
- Specified by:
setNull
in interfacePreparedStatement
- Throws:
SQLException
-
setBoolean
public void setBoolean(int columnIndex, boolean value) throws SQLException
- Specified by:
setBoolean
in interfacePreparedStatement
- Throws:
SQLException
-
setByte
public void setByte(int columnIndex, byte value) throws SQLException
- Specified by:
setByte
in interfacePreparedStatement
- Throws:
SQLException
-
setShort
public void setShort(int columnIndex, short value) throws SQLException
- Specified by:
setShort
in interfacePreparedStatement
- Throws:
SQLException
-
setInt
public void setInt(int columnIndex, int value) throws SQLException
- Specified by:
setInt
in interfacePreparedStatement
- Throws:
SQLException
-
setLong
public void setLong(int columnIndex, long value) throws SQLException
- Specified by:
setLong
in interfacePreparedStatement
- Throws:
SQLException
-
setFloat
public void setFloat(int columnIndex, float value) throws SQLException
- Specified by:
setFloat
in interfacePreparedStatement
- Throws:
SQLException
-
setDouble
public void setDouble(int columnIndex, double value) throws SQLException
- Specified by:
setDouble
in interfacePreparedStatement
- Throws:
SQLException
-
setBigDecimal
public void setBigDecimal(int columnIndex, BigDecimal value) throws SQLException
- Specified by:
setBigDecimal
in interfacePreparedStatement
- Throws:
SQLException
-
setString
public void setString(int columnIndex, String value) throws SQLException
- Specified by:
setString
in interfacePreparedStatement
- Throws:
SQLException
-
setBytes
public void setBytes(int columnIndex, byte[] value) throws SQLException
- Specified by:
setBytes
in interfacePreparedStatement
- Throws:
SQLException
-
setDate
public void setDate(int columnIndex, Date value) throws SQLException
- Specified by:
setDate
in interfacePreparedStatement
- Throws:
SQLException
-
setTime
public void setTime(int columnIndex, Time value) throws SQLException
- Specified by:
setTime
in interfacePreparedStatement
- Throws:
SQLException
-
setTimestamp
public void setTimestamp(int columnIndex, Timestamp value) throws SQLException
- Specified by:
setTimestamp
in interfacePreparedStatement
- Throws:
SQLException
-
setAsciiStream
public void setAsciiStream(int columnIndex, InputStream value, int length) throws SQLException
- Specified by:
setAsciiStream
in interfacePreparedStatement
- Throws:
SQLException
-
setUnicodeStream
public void setUnicodeStream(int columnIndex, InputStream value, int arg2) throws SQLException
- Specified by:
setUnicodeStream
in interfacePreparedStatement
- Throws:
SQLException
-
setBinaryStream
public void setBinaryStream(int columnIndex, InputStream value, int length) throws SQLException
- Specified by:
setBinaryStream
in interfacePreparedStatement
- Throws:
SQLException
-
clearParameters
public void clearParameters() throws SQLException
- Specified by:
clearParameters
in interfacePreparedStatement
- Throws:
SQLException
-
setObject
public void setObject(int columnIndex, Object value, int sqlType, int scale) throws SQLException
Implemented onsetObject(int,Object,int)
, discarding scale.- Specified by:
setObject
in interfacePreparedStatement
- Throws:
SQLException
-
setObject
public void setObject(int columnIndex, Object value, int sqlType) throws SQLException
- Specified by:
setObject
in interfacePreparedStatement
- Throws:
SQLException
-
setObject
public void setObject(int columnIndex, Object value) throws SQLException
- Specified by:
setObject
in interfacePreparedStatement
- Throws:
SQLException
-
execute
public boolean execute() throws SQLException
- Specified by:
execute
in interfacePreparedStatement
- Throws:
SQLException
-
execute
public boolean execute(String statement) throws SQLException
The prepared statement cannot be used for executing oter statements.- Specified by:
execute
in interfaceStatement
- Overrides:
execute
in classSPIStatement
- Throws:
SQLException
- indicating that this feature is not supported.
-
addBatch
public void addBatch() throws SQLException
- Specified by:
addBatch
in interfacePreparedStatement
- Throws:
SQLException
-
addBatch
public void addBatch(String statement) throws SQLException
The prepared statement cannot have other statements added too it.- Specified by:
addBatch
in interfaceStatement
- Overrides:
addBatch
in classSPIStatement
- Throws:
SQLException
- indicating that this feature is not supported.
-
setCharacterStream
public void setCharacterStream(int columnIndex, Reader value, int length) throws SQLException
- Specified by:
setCharacterStream
in interfacePreparedStatement
- Throws:
SQLException
-
setRef
public void setRef(int columnIndex, Ref value) throws SQLException
- Specified by:
setRef
in interfacePreparedStatement
- Throws:
SQLException
-
setBlob
public void setBlob(int columnIndex, Blob value) throws SQLException
- Specified by:
setBlob
in interfacePreparedStatement
- Throws:
SQLException
-
setClob
public void setClob(int columnIndex, Clob value) throws SQLException
- Specified by:
setClob
in interfacePreparedStatement
- Throws:
SQLException
-
setArray
public void setArray(int columnIndex, Array value) throws SQLException
- Specified by:
setArray
in interfacePreparedStatement
- Throws:
SQLException
-
getMetaData
public ResultSetMetaData getMetaData() throws SQLException
ResultSetMetaData is not yet supported.- Specified by:
getMetaData
in interfacePreparedStatement
- Throws:
SQLException
- indicating that this feature is not supported.
-
setDate
public void setDate(int columnIndex, Date value, Calendar cal) throws SQLException
- Specified by:
setDate
in interfacePreparedStatement
- Throws:
SQLException
-
setTime
public void setTime(int columnIndex, Time value, Calendar cal) throws SQLException
- Specified by:
setTime
in interfacePreparedStatement
- Throws:
SQLException
-
setTimestamp
public void setTimestamp(int columnIndex, Timestamp value, Calendar cal) throws SQLException
- Specified by:
setTimestamp
in interfacePreparedStatement
- Throws:
SQLException
-
setNull
public void setNull(int columnIndex, int sqlType, String typeName) throws SQLException
This method can (and is the only method that can, until JDBC 4.2 SQLType is implemented) assign a specific PostgreSQL type, by name, to a PreparedStatement parameter.However, to avoid a substantial behavior change in a 1.5.x minor release, its effect is limited for now. Any subsequent assignment of a non-null value for the parameter, using any of the setter methods or setObject-accepted classes from pre-JDBC 4.2, will reset the associated PostgreSQL type to what would have been assigned according to the JDBC
sqlType
or the type of the object.In contrast, setObject with any of the object types newly recognized in PL/Java 1.5.1 will not overwrite the PostgreSQL type assigned by this method, but will let it stand, on the assumption that the object's native to-Datum coercions will include one that applies to the type. If not, an exception will result.
The
sqlType
supplied here will be remembered, only to be used by the somewhat-functionally-impairedParameterMetaData
implementation. It is not checked for compatibility with the supplied PostgreSQLtypeName
in any way.- Specified by:
setNull
in interfacePreparedStatement
- Throws:
SQLException
-
setURL
public void setURL(int columnIndex, URL value) throws SQLException
- Specified by:
setURL
in interfacePreparedStatement
- Throws:
SQLException
-
getParameterMetaData
public ParameterMetaData getParameterMetaData() throws SQLException
Due to the design of theSPI_prepare
, it is currently impossible to obtain the correct parameter meta data before all the parameters have been set, hence a ParameterMetaData obtained prior to setting the paramteres will have all parameters set to the default typeTypes.VARCHAR
. Once the parameters have been set, a fair attempt is made to generate this object based on the supplied values.- Specified by:
getParameterMetaData
in interfacePreparedStatement
- Returns:
- The meta data for parameter values.
- Throws:
SQLException
-
executeBatchEntry
protected long executeBatchEntry(Object batchEntry) throws SQLException
- Overrides:
executeBatchEntry
in classSPIStatement
- Throws:
SQLException
-
setSQLXML
public void setSQLXML(int parameterIndex, SQLXML xmlObject) throws SQLException
- Specified by:
setSQLXML
in interfacePreparedStatement
- Throws:
SQLException
-
setNClob
public void setNClob(int parameterIndex, Reader reader) throws SQLException
- Specified by:
setNClob
in interfacePreparedStatement
- Throws:
SQLException
-
setNClob
public void setNClob(int parameterIndex, NClob value) throws SQLException
- Specified by:
setNClob
in interfacePreparedStatement
- Throws:
SQLException
-
setNClob
public void setNClob(int parameterIndex, Reader reader, long length) throws SQLException
- Specified by:
setNClob
in interfacePreparedStatement
- Throws:
SQLException
-
setBlob
public void setBlob(int parameterIndex, InputStream inputStream) throws SQLException
- Specified by:
setBlob
in interfacePreparedStatement
- Throws:
SQLException
-
setBlob
public void setBlob(int parameterIndex, InputStream inputStream, long length) throws SQLException
- Specified by:
setBlob
in interfacePreparedStatement
- Throws:
SQLException
-
setClob
public void setClob(int parameterIndex, Reader reader) throws SQLException
- Specified by:
setClob
in interfacePreparedStatement
- Throws:
SQLException
-
setClob
public void setClob(int parameterIndex, Reader reader, long length) throws SQLException
- Specified by:
setClob
in interfacePreparedStatement
- Throws:
SQLException
-
setNCharacterStream
public void setNCharacterStream(int parameterIndex, Reader value) throws SQLException
- Specified by:
setNCharacterStream
in interfacePreparedStatement
- Throws:
SQLException
-
setNCharacterStream
public void setNCharacterStream(int parameterIndex, Reader value, long length) throws SQLException
- Specified by:
setNCharacterStream
in interfacePreparedStatement
- Throws:
SQLException
-
setCharacterStream
public void setCharacterStream(int parameterIndex, Reader reader) throws SQLException
- Specified by:
setCharacterStream
in interfacePreparedStatement
- Throws:
SQLException
-
setCharacterStream
public void setCharacterStream(int parameterIndex, Reader reader, long length) throws SQLException
- Specified by:
setCharacterStream
in interfacePreparedStatement
- Throws:
SQLException
-
setBinaryStream
public void setBinaryStream(int parameterIndex, InputStream x) throws SQLException
- Specified by:
setBinaryStream
in interfacePreparedStatement
- Throws:
SQLException
-
setBinaryStream
public void setBinaryStream(int parameterIndex, InputStream x, long length) throws SQLException
- Specified by:
setBinaryStream
in interfacePreparedStatement
- Throws:
SQLException
-
setAsciiStream
public void setAsciiStream(int parameterIndex, InputStream x) throws SQLException
- Specified by:
setAsciiStream
in interfacePreparedStatement
- Throws:
SQLException
-
setAsciiStream
public void setAsciiStream(int parameterIndex, InputStream x, long length) throws SQLException
- Specified by:
setAsciiStream
in interfacePreparedStatement
- Throws:
SQLException
-
setNString
public void setNString(int parameterIndex, String value) throws SQLException
- Specified by:
setNString
in interfacePreparedStatement
- Throws:
SQLException
-
setRowId
public void setRowId(int parameterIndex, RowId x) throws SQLException
- Specified by:
setRowId
in interfacePreparedStatement
- Throws:
SQLException
-
-