public class IfxStatement extends java.lang.Object implements IfmxStatement
A Statement object is used for executing a static SQL statement and obtaining the results produced by it.
Only one ResultSet per Statement can be open at any point in time. Therefore, if the reading of one ResultSet is interleaved with the reading of another, each must have been generated by different Statements.
Connection.createStatement()
,
ResultSet
Modifier and Type | Field and Description |
---|---|
protected java.util.Vector<IfxObject> |
BatchParamVector |
protected java.util.Vector<java.lang.String> |
BatchVector |
protected boolean |
Closed |
java.lang.String |
commandString |
protected IfxResultSet |
currentResult |
protected boolean |
cursorOpen |
protected boolean |
executeBatchInProgress |
protected IfxConnection |
jconn |
protected int |
numqmarks |
protected IfxResultSetMetaData |
outputMetaData |
protected PreparedStatementCache |
pool |
protected boolean |
poolable |
protected IfxProtocol |
prot |
protected static short |
SGK_ALL_KEYS |
protected int[] |
SGK_indexes |
protected static short |
SGK_KEYS_BY_INDEX |
protected static short |
SGK_KEYS_BY_NAME |
protected IfxResultSetMetaData |
SGK_metaData |
protected java.lang.String[] |
SGK_names |
protected static short |
SGK_NO_KEYS |
protected IfxClientResultSet |
SGK_resultSet |
protected int |
statementType |
Modifier and Type | Method and Description |
---|---|
void |
addBatch(java.lang.String sql)
JDBC 2.0
Adds a SQL command to the current batch of commmands for the statement.
|
void |
cancel()
Cancel can be used by one thread to cancel a statement that
is being executed by another thread.
|
protected void |
chkAndSetGetRsltCalledFlag()
check to see if calledgetResultSet is already set ,
throw exception if its already set .
|
void |
clearBatch()
JDBC 2.0
Make the set of commands in the current batch empty.
|
void |
clearWarnings()
After this call getWarnings returns null until a new warning is
reported for this Statement.
|
void |
close()
In many cases, it is desirable to immediately release a
Statements's database and JDBC resources instead of waiting for
this to happen when it is automatically closed; the close
method provides this immediate release.
|
void |
closeOnCompletion() |
boolean |
execute(java.lang.String sql)
Execute a SQL statement that may return multiple results.
|
boolean |
execute(java.lang.String sql,
int autoGeneratedKeys) |
boolean |
execute(java.lang.String sql,
int[] columnIndexes) |
boolean |
execute(java.lang.String sql,
java.lang.String[] columnNames) |
int[] |
executeBatch()
JDBC 2.0
Submit a batch of commands to the database for execution.
|
protected boolean |
executeImpl()
Execute a SQL statement.
|
java.sql.ResultSet |
executeQuery(java.lang.String sql)
Execute a SQL statement that returns a single ResultSet.
|
java.sql.ResultSet |
executeQuery(java.lang.String sql,
boolean withHold)
Execute a SQL statement that returns a single ResultSet.
|
protected java.sql.ResultSet |
executeQueryImpl(boolean withHold,
boolean withReOptimzation)
Execute a SQL statement that returns a single ResultSet.
|
int |
executeUpdate(java.lang.String sql)
Execute a SQL INSERT, UPDATE or DELETE statement.
|
int |
executeUpdate(java.lang.String sql,
int autoGeneratedKeys)
Execute a SQL INSERT, UPDATE or DELETE statement.
|
int |
executeUpdate(java.lang.String sql,
int[] columnIndexes)
Execute a SQL INSERT, UPDATE or DELETE statement.
|
int |
executeUpdate(java.lang.String sql,
java.lang.String[] columnNames)
Execute a SQL INSERT, UPDATE or DELETE statement.
|
boolean |
getAutoFree()
Returns the autoFree flag
|
long |
getBigSerial()
Informix extension which returns the bigserial value of the last
row inserted.
|
IfxConnection |
getConnection()
Get the IfxConnection object reference from this staement.
|
java.lang.String |
getCursorName()
Get the cursor name for the statement
|
int |
getFetchBufferSize()
returns the fetch buffer size if set for this statement object
|
int |
getFetchDirection()
JDBC 2.0
Determine the fetch direction.
|
int |
getFetchSize()
JDBC 2.0
Determine the default fetch size.
|
java.sql.ResultSet |
getGeneratedKeys()
Return a resultSet containing the AutoGeneratedKeys returned
by the server for last execution of the statement.
|
int |
getMaxFieldSize()
The maxFieldSize limit (in bytes) is the maximum amount of data
returned for any column value; it only applies to BINARY,
VARBINARY, LONGVARBINARY, CHAR, VARCHAR, and LONGVARCHAR
columns.
|
int |
getMaxRows()
The maxRows limit is the maximum number of rows that a
ResultSet can contain.
|
boolean |
getMoreResults()
getMoreResults moves to a Statement's next result.
|
boolean |
getMoreResults(int current) |
int |
getQueryTimeout()
The queryTimeout limit is the number of seconds the driver will
wait for a Statement to execute.
|
java.sql.ResultSet |
getResultSet()
getResultSet returns the current result as a ResultSet.
|
int |
getResultSetConcurrency()
JDBC 2.0
Determine the result set concurrency.
|
int |
getResultSetHoldability() |
int |
getResultSetType()
JDBC 2.0
Determine the result set type.
|
int |
getSerial()
Informix extension which returns the serial value of the last
row inserted.
|
long |
getSerial8()
Informix extension which returns the serial8 value of the last
row inserted.
|
int |
getStatementType()
An Informix extention to return the statement type returned
by preparing the SQL statement.
|
int |
getUpdateCount()
getUpdateCount returns the current result, which should be an
integer value.
|
java.sql.SQLWarning |
getWarnings()
The first warning reported by calls on this Statement is
returned.
|
boolean |
isClosed() |
boolean |
isCloseOnCompletion() |
boolean |
isPoolable() |
boolean |
isWrapperFor(java.lang.Class<?> iface) |
protected void |
resetMethodCalledFlags()
Methods such as getResultSet() and getUpdateCount() may be called only once
for a particular resultset.
|
protected void |
scrubBatch()
clears members set while batch update was in progress
|
void |
setAutoFree(boolean flag)
Sets the autoFree flag if the server supports it.
|
void |
setCursorName(java.lang.String name)
setCursorName defines the SQL cursor name that will be used by
subsequent Statement execute methods.
|
void |
setEscapeProcessing(boolean enable)
If escape scanning is on (the default) the driver will do
escape substitution before sending the SQL to the database.
|
void |
setFetchBufferSize(int bufferSize)
An Informix extension that sets the buffer size for this Statement
object for fetch operation
This value will override any FET_BUF_SIZE connection level property
and is useful when OPTOFC property is set
Server will use this value as hint to determin the maximum buffer
size to send the data to the clients.
|
void |
setFetchDirection(int direction)
JDBC 2.0
Give a hint as to the direction in which the rows in a result set
will be processed.
|
void |
setFetchSize(int rows)
JDBC 2.0
Give the JDBC driver a hint as to the number of rows that should
be fetched from the database when more rows are needed.
|
void |
setMaxFieldSize(int max)
The maxFieldSize limit (in bytes) is set to limit the size of
data that can be returned for any column value; it only applies
to BINARY, VARBINARY, LONGVARBINARY, CHAR, VARCHAR, and
LONGVARCHAR fields.
|
void |
setMaxRows(int max)
The maxRows limit is set to limit the number of rows that any
ResultSet can contain.
|
void |
setPoolable(boolean poolable) |
void |
setQueryTimeout(int seconds)
The queryTimeout limit is the number of seconds the driver will
wait for a Statement to execute.
|
protected void |
setResultSetConcurrency(int resultSetConcurrencyType)
Check to see if the Concurrency Type is supported and either
set it or return an Exception.
|
protected void |
setResultSetType(int resultSetType)
Check to see if the ResultSet Type is supported and either
set it or return an Exception.
|
protected void |
setStatementType(int stype) |
protected void |
transferWarnings()
This method is called to transfer warnings reported on a statement
from IfxSqli object to the statement object
This is needed as resultset object and statement object share same
instance of IfxSqli class.
|
<T> T |
unwrap(java.lang.Class<T> iface) |
protected boolean cursorOpen
protected boolean poolable
protected IfxConnection jconn
protected IfxProtocol prot
public java.lang.String commandString
protected IfxResultSet currentResult
protected int numqmarks
protected java.util.Vector<java.lang.String> BatchVector
protected java.util.Vector<IfxObject> BatchParamVector
protected boolean executeBatchInProgress
protected IfxResultSetMetaData outputMetaData
protected int statementType
protected boolean Closed
protected static final short SGK_NO_KEYS
protected static final short SGK_ALL_KEYS
protected static final short SGK_KEYS_BY_INDEX
protected static final short SGK_KEYS_BY_NAME
protected int[] SGK_indexes
protected java.lang.String[] SGK_names
protected IfxResultSetMetaData SGK_metaData
protected IfxClientResultSet SGK_resultSet
protected final PreparedStatementCache pool
public java.sql.ResultSet executeQuery(java.lang.String sql) throws java.sql.SQLException
executeQuery
in interface java.sql.Statement
sql
- typically this is a static SQL SELECT statementjava.sql.SQLException
public java.sql.ResultSet executeQuery(java.lang.String sql, boolean withHold) throws java.sql.SQLException
executeQuery
in interface IfmxStatement
sql
- typically this is a static SQL SELECT statementwithHold
- use Cursor With Hold or notjava.sql.SQLException
public int executeUpdate(java.lang.String sql) throws java.sql.SQLException
executeUpdate
in interface java.sql.Statement
sql
- a SQL INSERT, UPDATE or DELETE statement or a SQL
statement that returns nothingjava.sql.SQLException
public int executeUpdate(java.lang.String sql, int autoGeneratedKeys) throws java.sql.SQLException
executeUpdate
in interface java.sql.Statement
sql
- a SQL INSERT, UPDATE or DELETE statement or a SQL
statement that returns nothingjava.sql.SQLException
public int executeUpdate(java.lang.String sql, int[] columnIndexes) throws java.sql.SQLException
executeUpdate
in interface java.sql.Statement
sql
- a SQL INSERT, UPDATE or DELETE statement or a SQL
statement that returns nothingjava.sql.SQLException
public int executeUpdate(java.lang.String sql, java.lang.String[] columnNames) throws java.sql.SQLException
executeUpdate
in interface java.sql.Statement
sql
- a SQL INSERT, UPDATE or DELETE statement or a SQL
statement that returns nothingjava.sql.SQLException
public java.sql.ResultSet getGeneratedKeys() throws java.sql.SQLException
getGeneratedKeys
in interface java.sql.Statement
java.sql.SQLException
public void close() throws java.sql.SQLException
Note: A Statement is automatically closed when it is garbage collected. When a Statement is closed its current ResultSet, if one exists, is also closed.
close
in interface java.lang.AutoCloseable
close
in interface java.sql.Statement
java.sql.SQLException
public int getMaxFieldSize() throws java.sql.SQLException
getMaxFieldSize
in interface java.sql.Statement
java.sql.SQLException
public void setMaxFieldSize(int max) throws java.sql.SQLException
setMaxFieldSize
in interface java.sql.Statement
max
- the new max column size limit; zero means unlimitedjava.sql.SQLException
public int getMaxRows() throws java.sql.SQLException
getMaxRows
in interface java.sql.Statement
java.sql.SQLException
public void setMaxRows(int max) throws java.sql.SQLException
setMaxRows
in interface java.sql.Statement
max
- the new max rows limit; zero means unlimitedjava.sql.SQLException
public void setEscapeProcessing(boolean enable) throws java.sql.SQLException
setEscapeProcessing
in interface java.sql.Statement
enable
- true to enable; false to disablejava.sql.SQLException
public int getQueryTimeout() throws java.sql.SQLException
getQueryTimeout
in interface java.sql.Statement
java.sql.SQLException
public void setQueryTimeout(int seconds) throws java.sql.SQLException
setQueryTimeout
in interface java.sql.Statement
seconds
- the new query timeout limit in seconds; zero means unlimitedjava.sql.SQLException
public void cancel() throws java.sql.SQLException
cancel
in interface java.sql.Statement
java.sql.SQLException
protected void transferWarnings() throws java.sql.SQLException
java.sql.SQLException
public java.sql.SQLWarning getWarnings() throws java.sql.SQLException
The warning chain is automatically cleared each time a statement is (re)executed.
Note: If you are processing a ResultSet then any warnings associated with ResultSet reads will be chained on the ResultSet object.
getWarnings
in interface java.sql.Statement
java.sql.SQLException
public void clearWarnings() throws java.sql.SQLException
clearWarnings
in interface java.sql.Statement
java.sql.SQLException
public void setCursorName(java.lang.String name) throws java.sql.SQLException
Note: By definition, positioned update/delete execution must be done by a different Statement than the one which generated the ResultSet being used for positioning. Also, cursor names must be unique within a Connection.
setCursorName
in interface java.sql.Statement
name
- the new cursor name.java.sql.SQLException
public boolean execute(java.lang.String sql) throws java.sql.SQLException
execute
in interface java.sql.Statement
sql
- any SQL statementjava.sql.SQLException
getResultSet()
,
getUpdateCount()
,
getMoreResults()
public boolean execute(java.lang.String sql, int autoGeneratedKeys) throws java.sql.SQLException
execute
in interface java.sql.Statement
java.sql.SQLException
public boolean execute(java.lang.String sql, int[] columnIndexes) throws java.sql.SQLException
execute
in interface java.sql.Statement
java.sql.SQLException
public boolean execute(java.lang.String sql, java.lang.String[] columnNames) throws java.sql.SQLException
execute
in interface java.sql.Statement
java.sql.SQLException
public java.sql.ResultSet getResultSet() throws java.sql.SQLException
getResultSet
in interface java.sql.Statement
java.sql.SQLException
execute(java.lang.String)
public int getUpdateCount() throws java.sql.SQLException
The only way to tell for sure that the result is an update count is to first test to see if it is a ResultSet. If it is not a ResultSet it is an update count.
getUpdateCount
in interface java.sql.Statement
java.sql.SQLException
public boolean getMoreResults() throws java.sql.SQLException
getMoreResults
in interface java.sql.Statement
java.sql.SQLException
execute(java.lang.String)
public java.lang.String getCursorName() throws java.sql.SQLException
java.sql.SQLException
public IfxConnection getConnection() throws java.sql.SQLException
getConnection
in interface java.sql.Statement
java.sql.SQLException
protected java.sql.ResultSet executeQueryImpl(boolean withHold, boolean withReOptimzation) throws java.sql.SQLException
withHold
- use Cursor With Hold or notjava.sql.SQLException
protected boolean executeImpl() throws java.sql.SQLException
java.sql.SQLException
public int getSerial() throws java.sql.SQLException
getSerial
in interface IfmxStatement
java.sql.SQLException
public long getSerial8() throws java.sql.SQLException
getSerial8
in interface IfmxStatement
java.sql.SQLException
public void setFetchDirection(int direction) throws java.sql.SQLException
setFetchDirection
in interface java.sql.Statement
direction
- the initial direction for processing rowsjava.sql.SQLException
- if a database-access error occurs or direction
is not one of ResultSet.FETCH_FORWARD, ResultSet.FETCH_REVERSE, or
ResultSet.FETCH_UNKNOWNpublic int getFetchDirection() throws java.sql.SQLException
getFetchDirection
in interface java.sql.Statement
java.sql.SQLException
- if a database-access error occurspublic void setFetchSize(int rows) throws java.sql.SQLException
setFetchSize
in interface java.sql.Statement
rows
- the number of rows to fetchjava.sql.SQLException
- if a database-access error occurs, or the
condition 0 <= rows <= this.getMaxRows() is not satisfied.public int getFetchSize() throws java.sql.SQLException
getFetchSize
in interface java.sql.Statement
java.sql.SQLException
public int getResultSetConcurrency() throws java.sql.SQLException
getResultSetConcurrency
in interface java.sql.Statement
java.sql.SQLException
public int getResultSetType() throws java.sql.SQLException
getResultSetType
in interface java.sql.Statement
java.sql.SQLException
public void addBatch(java.lang.String sql) throws java.sql.SQLException
addBatch
in interface java.sql.Statement
sql
- typically this is a static SQL INSERT or UPDATE statementjava.sql.SQLException
- if a database-access error occurs, or the
driver does not support batch statementspublic void clearBatch() throws java.sql.SQLException
clearBatch
in interface java.sql.Statement
java.sql.SQLException
- if a database-access error occurs, or the
driver does not support batch statementsprotected void scrubBatch() throws java.sql.SQLException
java.sql.SQLException
public int[] executeBatch() throws java.sql.SQLException
executeBatch
in interface java.sql.Statement
java.sql.SQLException
- if a database-access error occurs, or the
driver does not support batch statementsprotected void setResultSetType(int resultSetType) throws java.sql.SQLException
java.sql.SQLException
protected void setResultSetConcurrency(int resultSetConcurrencyType) throws java.sql.SQLException
java.sql.SQLException
public void setAutoFree(boolean flag)
setAutoFree
in interface IfmxStatement
flag
- Indicates whether the autofree property is true (set) or
false.public boolean getAutoFree()
getAutoFree
in interface IfmxStatement
protected void setStatementType(int stype)
public int getStatementType()
IfmxStatement
getStatementType
in interface IfmxStatement
public boolean getMoreResults(int current) throws java.sql.SQLException
getMoreResults
in interface java.sql.Statement
java.sql.SQLException
public int getResultSetHoldability() throws java.sql.SQLException
getResultSetHoldability
in interface java.sql.Statement
java.sql.SQLException
protected void chkAndSetGetRsltCalledFlag() throws java.sql.SQLException
java.sql.SQLException
protected void resetMethodCalledFlags()
public long getBigSerial() throws java.sql.SQLException
getBigSerial
in interface IfmxStatement
java.sql.SQLException
public boolean isClosed() throws java.sql.SQLException
isClosed
in interface java.sql.Statement
java.sql.SQLException
public boolean isPoolable() throws java.sql.SQLException
isPoolable
in interface java.sql.Statement
java.sql.SQLException
public void setPoolable(boolean poolable) throws java.sql.SQLException
setPoolable
in interface java.sql.Statement
java.sql.SQLException
public boolean isWrapperFor(java.lang.Class<?> iface) throws java.sql.SQLException
isWrapperFor
in interface java.sql.Wrapper
java.sql.SQLException
public <T> T unwrap(java.lang.Class<T> iface) throws java.sql.SQLException
unwrap
in interface java.sql.Wrapper
java.sql.SQLException
public void setFetchBufferSize(int bufferSize)
IfmxStatement
setFetchBufferSize
in interface IfmxStatement
bufferSize
- : number of bytes not exceeding 2GBpublic int getFetchBufferSize()
IfmxStatement
getFetchBufferSize
in interface IfmxStatement
public void closeOnCompletion() throws java.sql.SQLException
closeOnCompletion
in interface java.sql.Statement
java.sql.SQLException
public boolean isCloseOnCompletion() throws java.sql.SQLException
isCloseOnCompletion
in interface java.sql.Statement
java.sql.SQLException