- java.lang.Object
-
- org.postgresql.pljava.jdbc.SPIStatement
-
- All Implemented Interfaces:
AutoCloseable
,Statement
,Wrapper
,SPIReadOnlyControl
- Direct Known Subclasses:
SPIPreparedStatement
public class SPIStatement extends Object implements Statement, SPIReadOnlyControl
Implementation ofStatement
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 SPIStatement(SPIConnection conn)
-
Method Summary
Modifier and Type Method Description void
addBatch(String statement)
void
cancel()
void
clearBatch()
void
clearReadOnly()
Specify that the statement, when next executed, will have haveread_only
set tofalse
unconditionally.void
clearWarnings()
void
close()
void
closeOnCompletion()
void
defaultReadOnly()
Specify that the statement, when next executed, will have the behavior recommended in the PostgreSQL SPI documentation:read_only
will be set totrue
if the currently-executing PL/Java function is declaredIMMUTABLE
,false
otherwise.boolean
execute(String statement)
boolean
execute(String statement, int autoGeneratedKeys)
Return of auto generated keys is not yet supported.boolean
execute(String statement, int[] columnIndexes)
Return of auto generated keys is not yet supported.boolean
execute(String statement, String[] columnNames)
Return of auto generated keys is not yet supported.int[]
executeBatch()
protected long
executeBatchEntry(Object batchEntry)
long[]
executeLargeBatch()
protected boolean
executePlan(ExecutionPlan plan, Object[] paramValues)
ResultSet
executeQuery(String statement)
int
executeUpdate(String statement)
int
executeUpdate(String statement, int autoGeneratedKeys)
Return of auto generated keys is not yet supported.int
executeUpdate(String statement, int[] columnIndexes)
Return of auto generated keys is not yet supported.int
executeUpdate(String statement, String[] columnNames)
Return of auto generated keys is not yet supported.void
forceReadOnly()
Specify that the statement, when next executed, will have haveread_only
set totrue
unconditionally.Connection
getConnection()
Returns the Connection from that created this statement.int
getFetchDirection()
int
getFetchSize()
ResultSet
getGeneratedKeys()
long
getLargeUpdateCount()
int
getMaxFieldSize()
int
getMaxRows()
boolean
getMoreResults()
boolean
getMoreResults(int current)
int
getQueryTimeout()
ResultSet
getResultSet()
int
getResultSetConcurrency()
int
getResultSetHoldability()
int
getResultSetType()
int
getUpdateCount()
SQLWarning
getWarnings()
protected void
internalAddBatch(Object batch)
The argument is either aString
containing SQL (if from aStatement
, or anObject
array of length three (if from aPreparedStatement
) holding parameter values, SQL types, and PG type Oids.boolean
isClosed()
boolean
isCloseOnCompletion()
boolean
isPoolable()
boolean
isWrapperFor(Class<?> iface)
void
setCursorName(String cursorName)
void
setEscapeProcessing(boolean enable)
void
setFetchDirection(int direction)
OnlyResultSet.FETCH_FORWARD
is supported.void
setFetchSize(int size)
void
setMaxFieldSize(int size)
void
setMaxRows(int rows)
void
setPoolable(boolean poolable)
void
setQueryTimeout(int seconds)
<T> T
unwrap(Class<T> iface)
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.sql.Statement
enquoteIdentifier, enquoteLiteral, enquoteNCharLiteral, executeLargeUpdate, executeLargeUpdate, executeLargeUpdate, executeLargeUpdate, getLargeMaxRows, isSimpleIdentifier, setLargeMaxRows
-
-
-
-
Constructor Detail
-
SPIStatement
public SPIStatement(SPIConnection conn)
-
-
Method Detail
-
addBatch
public void addBatch(String statement) throws SQLException
- Specified by:
addBatch
in interfaceStatement
- Throws:
SQLException
-
cancel
public void cancel() throws SQLException
- Specified by:
cancel
in interfaceStatement
- Throws:
SQLException
-
clearBatch
public void clearBatch() throws SQLException
- Specified by:
clearBatch
in interfaceStatement
- Throws:
SQLException
-
clearWarnings
public void clearWarnings() throws SQLException
- Specified by:
clearWarnings
in interfaceStatement
- Throws:
SQLException
-
close
public void close() throws SQLException
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceStatement
- Throws:
SQLException
-
execute
public boolean execute(String statement) throws SQLException
- Specified by:
execute
in interfaceStatement
- Throws:
SQLException
-
executePlan
protected boolean executePlan(ExecutionPlan plan, Object[] paramValues) throws SQLException
- Throws:
SQLException
-
execute
public boolean execute(String statement, int autoGeneratedKeys) throws SQLException
Return of auto generated keys is not yet supported.- Specified by:
execute
in interfaceStatement
- Throws:
SQLException
- indicating that this feature is not supported.
-
execute
public boolean execute(String statement, int[] columnIndexes) throws SQLException
Return of auto generated keys is not yet supported.- Specified by:
execute
in interfaceStatement
- Throws:
SQLException
- indicating that this feature is not supported.
-
execute
public boolean execute(String statement, String[] columnNames) throws SQLException
Return of auto generated keys is not yet supported.- Specified by:
execute
in interfaceStatement
- Throws:
SQLException
- indicating that this feature is not supported.
-
executeBatch
public int[] executeBatch() throws SQLException
- Specified by:
executeBatch
in interfaceStatement
- Throws:
SQLException
-
executeLargeBatch
public long[] executeLargeBatch() throws SQLException
- Specified by:
executeLargeBatch
in interfaceStatement
- Throws:
SQLException
-
executeQuery
public ResultSet executeQuery(String statement) throws SQLException
- Specified by:
executeQuery
in interfaceStatement
- Throws:
SQLException
-
executeUpdate
public int executeUpdate(String statement) throws SQLException
- Specified by:
executeUpdate
in interfaceStatement
- Throws:
SQLException
-
executeUpdate
public int executeUpdate(String statement, int autoGeneratedKeys) throws SQLException
Return of auto generated keys is not yet supported.- Specified by:
executeUpdate
in interfaceStatement
- Throws:
SQLException
- indicating that this feature is not supported.
-
executeUpdate
public int executeUpdate(String statement, int[] columnIndexes) throws SQLException
Return of auto generated keys is not yet supported.- Specified by:
executeUpdate
in interfaceStatement
- Throws:
SQLException
- indicating that this feature is not supported.
-
executeUpdate
public int executeUpdate(String statement, String[] columnNames) throws SQLException
Return of auto generated keys is not yet supported.- Specified by:
executeUpdate
in interfaceStatement
- Throws:
SQLException
- indicating that this feature is not supported.
-
getConnection
public Connection getConnection() throws SQLException
Returns the Connection from that created this statement.- Specified by:
getConnection
in interfaceStatement
- Throws:
SQLException
- if the statement is closed.
-
getFetchDirection
public int getFetchDirection() throws SQLException
- Specified by:
getFetchDirection
in interfaceStatement
- Throws:
SQLException
-
getFetchSize
public int getFetchSize() throws SQLException
- Specified by:
getFetchSize
in interfaceStatement
- Throws:
SQLException
-
getGeneratedKeys
public ResultSet getGeneratedKeys() throws SQLException
- Specified by:
getGeneratedKeys
in interfaceStatement
- Throws:
SQLException
-
getMaxFieldSize
public int getMaxFieldSize() throws SQLException
- Specified by:
getMaxFieldSize
in interfaceStatement
- Throws:
SQLException
-
getMaxRows
public int getMaxRows() throws SQLException
- Specified by:
getMaxRows
in interfaceStatement
- Throws:
SQLException
-
getMoreResults
public boolean getMoreResults() throws SQLException
- Specified by:
getMoreResults
in interfaceStatement
- Throws:
SQLException
-
getMoreResults
public boolean getMoreResults(int current) throws SQLException
- Specified by:
getMoreResults
in interfaceStatement
- Throws:
SQLException
-
getQueryTimeout
public int getQueryTimeout() throws SQLException
- Specified by:
getQueryTimeout
in interfaceStatement
- Throws:
SQLException
-
getResultSet
public ResultSet getResultSet() throws SQLException
- Specified by:
getResultSet
in interfaceStatement
- Throws:
SQLException
-
getResultSetConcurrency
public int getResultSetConcurrency()
- Specified by:
getResultSetConcurrency
in interfaceStatement
-
getResultSetHoldability
public int getResultSetHoldability() throws SQLException
- Specified by:
getResultSetHoldability
in interfaceStatement
- Throws:
SQLException
-
getResultSetType
public int getResultSetType()
- Specified by:
getResultSetType
in interfaceStatement
-
getUpdateCount
public int getUpdateCount() throws SQLException
- Specified by:
getUpdateCount
in interfaceStatement
- Throws:
SQLException
-
getLargeUpdateCount
public long getLargeUpdateCount() throws SQLException
- Specified by:
getLargeUpdateCount
in interfaceStatement
- Throws:
SQLException
-
getWarnings
public SQLWarning getWarnings() throws SQLException
- Specified by:
getWarnings
in interfaceStatement
- Throws:
SQLException
-
setCursorName
public void setCursorName(String cursorName) throws SQLException
- Specified by:
setCursorName
in interfaceStatement
- Throws:
SQLException
-
setEscapeProcessing
public void setEscapeProcessing(boolean enable) throws SQLException
- Specified by:
setEscapeProcessing
in interfaceStatement
- Throws:
SQLException
-
setFetchDirection
public void setFetchDirection(int direction) throws SQLException
OnlyResultSet.FETCH_FORWARD
is supported.- Specified by:
setFetchDirection
in interfaceStatement
- Throws:
SQLException
- indicating that this feature is not supported for other values ondirection
.
-
setFetchSize
public void setFetchSize(int size) throws SQLException
- Specified by:
setFetchSize
in interfaceStatement
- Throws:
SQLException
-
setMaxFieldSize
public void setMaxFieldSize(int size) throws SQLException
- Specified by:
setMaxFieldSize
in interfaceStatement
- Throws:
SQLException
-
setMaxRows
public void setMaxRows(int rows) throws SQLException
- Specified by:
setMaxRows
in interfaceStatement
- Throws:
SQLException
-
setQueryTimeout
public void setQueryTimeout(int seconds) throws SQLException
- Specified by:
setQueryTimeout
in interfaceStatement
- Throws:
SQLException
-
internalAddBatch
protected void internalAddBatch(Object batch) throws SQLException
The argument is either aString
containing SQL (if from aStatement
, or anObject
array of length three (if from aPreparedStatement
) holding parameter values, SQL types, and PG type Oids.- Throws:
SQLException
-
executeBatchEntry
protected long executeBatchEntry(Object batchEntry) throws SQLException
- Throws:
SQLException
-
isWrapperFor
public boolean isWrapperFor(Class<?> iface) throws SQLException
- Specified by:
isWrapperFor
in interfaceWrapper
- Throws:
SQLException
-
unwrap
public <T> T unwrap(Class<T> iface) throws SQLException
- Specified by:
unwrap
in interfaceWrapper
- Throws:
SQLException
-
isCloseOnCompletion
public boolean isCloseOnCompletion() throws SQLException
- Specified by:
isCloseOnCompletion
in interfaceStatement
- Throws:
SQLException
-
setPoolable
public void setPoolable(boolean poolable) throws SQLException
- Specified by:
setPoolable
in interfaceStatement
- Throws:
SQLException
-
isPoolable
public boolean isPoolable() throws SQLException
- Specified by:
isPoolable
in interfaceStatement
- Throws:
SQLException
-
isClosed
public boolean isClosed() throws SQLException
- Specified by:
isClosed
in interfaceStatement
- Throws:
SQLException
-
closeOnCompletion
public void closeOnCompletion() throws SQLException
- Specified by:
closeOnCompletion
in interfaceStatement
- Throws:
SQLException
-
defaultReadOnly
public void defaultReadOnly()
Description copied from interface:SPIReadOnlyControl
Specify that the statement, when next executed, will have the behavior recommended in the PostgreSQL SPI documentation:read_only
will be set totrue
if the currently-executing PL/Java function is declaredIMMUTABLE
,false
otherwise.- Specified by:
defaultReadOnly
in interfaceSPIReadOnlyControl
-
forceReadOnly
public void forceReadOnly()
Description copied from interface:SPIReadOnlyControl
Specify that the statement, when next executed, will have haveread_only
set totrue
unconditionally.- Specified by:
forceReadOnly
in interfaceSPIReadOnlyControl
-
clearReadOnly
public void clearReadOnly()
Description copied from interface:SPIReadOnlyControl
Specify that the statement, when next executed, will have haveread_only
set tofalse
unconditionally.- Specified by:
clearReadOnly
in interfaceSPIReadOnlyControl
-
-