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.
|
java.sql.Connection |
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.Statementsql - typically this is a static SQL SELECT statementjava.sql.SQLExceptionpublic java.sql.ResultSet executeQuery(java.lang.String sql,
boolean withHold)
throws java.sql.SQLException
executeQuery in interface IfmxStatementsql - typically this is a static SQL SELECT statementwithHold - use Cursor With Hold or notjava.sql.SQLExceptionpublic int executeUpdate(java.lang.String sql)
throws java.sql.SQLException
executeUpdate in interface java.sql.Statementsql - a SQL INSERT, UPDATE or DELETE statement or a SQL
statement that returns nothingjava.sql.SQLExceptionpublic int executeUpdate(java.lang.String sql,
int autoGeneratedKeys)
throws java.sql.SQLException
executeUpdate in interface java.sql.Statementsql - a SQL INSERT, UPDATE or DELETE statement or a SQL
statement that returns nothingjava.sql.SQLExceptionpublic int executeUpdate(java.lang.String sql,
int[] columnIndexes)
throws java.sql.SQLException
executeUpdate in interface java.sql.Statementsql - a SQL INSERT, UPDATE or DELETE statement or a SQL
statement that returns nothingjava.sql.SQLExceptionpublic int executeUpdate(java.lang.String sql,
java.lang.String[] columnNames)
throws java.sql.SQLException
executeUpdate in interface java.sql.Statementsql - a SQL INSERT, UPDATE or DELETE statement or a SQL
statement that returns nothingjava.sql.SQLExceptionpublic java.sql.ResultSet getGeneratedKeys()
throws java.sql.SQLException
getGeneratedKeys in interface java.sql.Statementjava.sql.SQLExceptionpublic 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.AutoCloseableclose in interface java.sql.Statementjava.sql.SQLExceptionpublic int getMaxFieldSize()
throws java.sql.SQLException
getMaxFieldSize in interface java.sql.Statementjava.sql.SQLExceptionpublic void setMaxFieldSize(int max)
throws java.sql.SQLException
setMaxFieldSize in interface java.sql.Statementmax - the new max column size limit; zero means unlimitedjava.sql.SQLExceptionpublic int getMaxRows()
throws java.sql.SQLException
getMaxRows in interface java.sql.Statementjava.sql.SQLExceptionpublic void setMaxRows(int max)
throws java.sql.SQLException
setMaxRows in interface java.sql.Statementmax - the new max rows limit; zero means unlimitedjava.sql.SQLExceptionpublic void setEscapeProcessing(boolean enable)
throws java.sql.SQLException
setEscapeProcessing in interface java.sql.Statementenable - true to enable; false to disablejava.sql.SQLExceptionpublic int getQueryTimeout()
throws java.sql.SQLException
getQueryTimeout in interface java.sql.Statementjava.sql.SQLExceptionpublic void setQueryTimeout(int seconds)
throws java.sql.SQLException
setQueryTimeout in interface java.sql.Statementseconds - the new query timeout limit in seconds; zero means unlimitedjava.sql.SQLExceptionpublic void cancel()
throws java.sql.SQLException
cancel in interface java.sql.Statementjava.sql.SQLExceptionprotected void transferWarnings()
throws java.sql.SQLException
java.sql.SQLExceptionpublic 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.Statementjava.sql.SQLExceptionpublic void clearWarnings()
throws java.sql.SQLException
clearWarnings in interface java.sql.Statementjava.sql.SQLExceptionpublic 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.Statementname - the new cursor name.java.sql.SQLExceptionpublic boolean execute(java.lang.String sql)
throws java.sql.SQLException
execute in interface java.sql.Statementsql - any SQL statementjava.sql.SQLExceptiongetResultSet(),
getUpdateCount(),
getMoreResults()public boolean execute(java.lang.String sql,
int autoGeneratedKeys)
throws java.sql.SQLException
execute in interface java.sql.Statementjava.sql.SQLExceptionpublic boolean execute(java.lang.String sql,
int[] columnIndexes)
throws java.sql.SQLException
execute in interface java.sql.Statementjava.sql.SQLExceptionpublic boolean execute(java.lang.String sql,
java.lang.String[] columnNames)
throws java.sql.SQLException
execute in interface java.sql.Statementjava.sql.SQLExceptionpublic java.sql.ResultSet getResultSet()
throws java.sql.SQLException
getResultSet in interface java.sql.Statementjava.sql.SQLExceptionexecute(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.Statementjava.sql.SQLExceptionpublic boolean getMoreResults()
throws java.sql.SQLException
getMoreResults in interface java.sql.Statementjava.sql.SQLExceptionexecute(java.lang.String)public java.lang.String getCursorName()
throws java.sql.SQLException
java.sql.SQLExceptionpublic java.sql.Connection getConnection()
throws java.sql.SQLException
getConnection in interface java.sql.Statementjava.sql.SQLExceptionprotected java.sql.ResultSet executeQueryImpl(boolean withHold,
boolean withReOptimzation)
throws java.sql.SQLException
withHold - use Cursor With Hold or notjava.sql.SQLExceptionprotected boolean executeImpl()
throws java.sql.SQLException
java.sql.SQLExceptionpublic int getSerial()
throws java.sql.SQLException
getSerial in interface IfmxStatementjava.sql.SQLExceptionpublic long getSerial8()
throws java.sql.SQLException
getSerial8 in interface IfmxStatementjava.sql.SQLExceptionpublic void setFetchDirection(int direction)
throws java.sql.SQLException
setFetchDirection in interface java.sql.Statementdirection - 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.Statementjava.sql.SQLException - if a database-access error occurspublic void setFetchSize(int rows)
throws java.sql.SQLException
setFetchSize in interface java.sql.Statementrows - 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.Statementjava.sql.SQLExceptionpublic int getResultSetConcurrency()
throws java.sql.SQLException
getResultSetConcurrency in interface java.sql.Statementjava.sql.SQLExceptionpublic int getResultSetType()
throws java.sql.SQLException
getResultSetType in interface java.sql.Statementjava.sql.SQLExceptionpublic void addBatch(java.lang.String sql)
throws java.sql.SQLException
addBatch in interface java.sql.Statementsql - 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.Statementjava.sql.SQLException - if a database-access error occurs, or the
driver does not support batch statementsprotected void scrubBatch()
throws java.sql.SQLException
java.sql.SQLExceptionpublic int[] executeBatch()
throws java.sql.SQLException
executeBatch in interface java.sql.Statementjava.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.SQLExceptionprotected void setResultSetConcurrency(int resultSetConcurrencyType)
throws java.sql.SQLException
java.sql.SQLExceptionpublic void setAutoFree(boolean flag)
setAutoFree in interface IfmxStatementflag - Indicates whether the autofree property is true (set) or
false.public boolean getAutoFree()
getAutoFree in interface IfmxStatementprotected void setStatementType(int stype)
public int getStatementType()
IfmxStatementgetStatementType in interface IfmxStatementpublic boolean getMoreResults(int current)
throws java.sql.SQLException
getMoreResults in interface java.sql.Statementjava.sql.SQLExceptionpublic int getResultSetHoldability()
throws java.sql.SQLException
getResultSetHoldability in interface java.sql.Statementjava.sql.SQLExceptionprotected void chkAndSetGetRsltCalledFlag()
throws java.sql.SQLException
java.sql.SQLExceptionprotected void resetMethodCalledFlags()
public long getBigSerial()
throws java.sql.SQLException
getBigSerial in interface IfmxStatementjava.sql.SQLExceptionpublic boolean isClosed()
throws java.sql.SQLException
isClosed in interface java.sql.Statementjava.sql.SQLExceptionpublic boolean isPoolable()
throws java.sql.SQLException
isPoolable in interface java.sql.Statementjava.sql.SQLExceptionpublic void setPoolable(boolean poolable)
throws java.sql.SQLException
setPoolable in interface java.sql.Statementjava.sql.SQLExceptionpublic boolean isWrapperFor(java.lang.Class<?> iface)
throws java.sql.SQLException
isWrapperFor in interface java.sql.Wrapperjava.sql.SQLExceptionpublic <T> T unwrap(java.lang.Class<T> iface)
throws java.sql.SQLException
unwrap in interface java.sql.Wrapperjava.sql.SQLExceptionpublic void setFetchBufferSize(int bufferSize)
IfmxStatementsetFetchBufferSize in interface IfmxStatementbufferSize - : number of bytes not exceeding 2GBpublic int getFetchBufferSize()
IfmxStatementgetFetchBufferSize in interface IfmxStatementpublic void closeOnCompletion()
throws java.sql.SQLException
closeOnCompletion in interface java.sql.Statementjava.sql.SQLExceptionpublic boolean isCloseOnCompletion()
throws java.sql.SQLException
isCloseOnCompletion in interface java.sql.Statementjava.sql.SQLException