ca.idms.jdbc
Class IdmsStatement

java.lang.Object
  extended by ca.idms.io.TraceObject
      extended by ca.idms.jdbc.IdmsJdbcObject
          extended by ca.idms.jdbc.IdmsResultObject
              extended by ca.idms.jdbc.IdmsStatement
All Implemented Interfaces:
Trace, SQLState, java.sql.Statement, java.sql.Wrapper
Direct Known Subclasses:
IdmsPreparedStatement, IdmsReceivedCursor

public class IdmsStatement
extends IdmsResultObject
implements java.sql.Statement

Represents a JDBC statement.

Author:
Dave Ross
See Also:
IdmsJdbcObject, IdmsConnection, IdmsPreparedStatement, IdmsResultSet

Field Summary
 
Fields inherited from class ca.idms.jdbc.IdmsJdbcObject
FAKE_METHODS, FAKE_SUPPORT, fakeSupport, MESSAGES
 
Fields inherited from class ca.idms.io.TraceObject
exclude, EXCLUDE, FALSE, include, INCLUDE, logWriter, PREFIX, PROPERTIES_FILE, PROPERTIES_KEY, snap, SNAP, SNAP_BYTES, SNAP_NATIVE, SNAP_OBJECT, SNAP_SQL, snapBytes, snapNative, snapObject, snapSql, stub, trace, TRACE, TRACE_FILE, TRACE_LIFE, TRACE_NATIVE, TRACE_PRODUCT, traceLife, traceNative, traceStream, TRUE
 
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
 
Fields inherited from interface ca.idms.qcli.SQLState
SQL_00000, SQL_01000, SQL_01004, SQL_07001, SQL_07009, SQL_08001, SQL_08002, SQL_08003, SQL_08004, SQL_08006, SQL_08007, SQL_0A000, SQL_21000, SQL_22000, SQL_22001, SQL_22003, SQL_22005, SQL_22007, SQL_24000, SQL_25000, SQL_3C000, SQL_40000, SQL_42000, SQL_HY000, SQL_HY004, SQL_HY009, SQL_HY010, SQL_HY024, SQL_HY106, SQL_HYC00
 
Method Summary
 void addBatch(java.lang.String sql)
          Adds an SQL statement to the list of batch updates.
 void cancel()
          Cancel can be used by one thread to cancel a statement that is being executed by another thread.
 void clearBatch()
          Clears the list of batch updates.
 void close()
          Releases all local resources held by this Statement.
 boolean execute(java.lang.String sql)
          Execute a SQL statement that may return multiple results.
 boolean execute(java.lang.String sql, int key)
          Executes an IDMS statement.
 boolean execute(java.lang.String sql, int[] index)
          Executes an IDMS statement.
 boolean execute(java.lang.String sql, java.lang.String[] names)
          Executes an IDMS statement.
 int[] executeBatch()
          Executes the current set of batch updates.
 java.sql.ResultSet executeQuery(java.lang.String sql)
          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 key)
          Executes an IDMS update statement.
 int executeUpdate(java.lang.String sql, int[] index)
          Executes an IDMS update statement.
 int executeUpdate(java.lang.String sql, java.lang.String[] names)
          Executes an IDMS update statement.
protected  void finalize()
          Cleans up when the statement is gc'd.
protected  java.lang.Object get(java.lang.reflect.Field f)
          Overrides the default get method to allow the default snap method access to the value of a non-public variable.
 java.sql.Connection getConnection()
          Gets the Connection.
 java.sql.ResultSet getGeneratedKeys()
          CA IDMS does not support automatically generated keys.
 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()
          Moves to the "next" ResultSet.
 boolean getMoreResults(int current)
          Moves to the "next" ResultSet, disposing of any open ones as specified Starting with CA IDMS r17, multiple results are supported.
 int getQueryTimeout()
          Gets the reply timeout for this IdmsStatement object.
 java.sql.ResultSet getResultSet()
          Returns the current result as a ResultSet.
 int getResultSetConcurrency()
          Gets the ResultSet concurrency.
 int getResultSetHoldability()
          For CA IDMS ResultSet holdability is a Connection attribute.
 int getResultSetType()
          Gets the ResultSet type.
 int getUpdateCount()
          Returns the current result as an update count.
 boolean isPoolable()
          Returns a value indicating whether or not the Statement should be pooled by a connection pool manager.
 void setCursorName(java.lang.String s)
          Defines a cursor name to use for positioned updates and deletes.
 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 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 enable)
          Allows an application to set a hint to the connection pool manager as to whether a statement should be pooled or not.
 void setQueryTimeout(int seconds)
          Sets the reply timeout for this Statement object.
 
Methods inherited from class ca.idms.jdbc.IdmsResultObject
getFetchDirection, getFetchSize, isClosed, setFetchDirection, setFetchSize
 
Methods inherited from class ca.idms.jdbc.IdmsJdbcObject
clearWarnings, getWarnings, hasCursor, hasUpdate, isStarted, isSuspended, isWrapperFor, notifyStatementError, unwrap
 
Methods inherited from class ca.idms.io.TraceObject
getBoolean, getClasses, getInteger, getProperty, listProperties, message, parseList, print, print, print, println, println, snap, snap, snap, snap, snap, snap, snap, toHex, toHex, toHex, toHex, toHex, toString, trace, trace, trace, trace, trace, trace, traceEntry, unloadProperties
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.sql.Statement
clearWarnings, getFetchDirection, getFetchSize, getWarnings, isClosed, setFetchDirection, setFetchSize
 
Methods inherited from interface java.sql.Wrapper
isWrapperFor, unwrap
 

Method Detail

finalize

protected void finalize()
                 throws java.lang.Throwable
Cleans up when the statement is gc'd.

Overrides:
finalize in class TraceObject
Throws:
java.lang.Throwable - unlikely

get

protected java.lang.Object get(java.lang.reflect.Field f)
                        throws java.lang.IllegalAccessException
Overrides the default get method to allow the default snap method access to the value of a non-public variable.

Overrides:
get in class IdmsResultObject
Parameters:
f - a Field returned by Class.getDeclaredFields
Returns:
the Object named by f
Throws:
java.lang.IllegalAccessException - should not really happen, but Field.get requires it
See Also:
TraceObject.snap, TraceObject.snap()

cancel

public void cancel()
            throws java.sql.SQLException
Cancel can be used by one thread to cancel a statement that is being executed by another thread.

Specified by:
cancel in interface java.sql.Statement
Throws:
java.sql.SQLException - if a database-access error occurs.

close

public void close()
           throws java.sql.SQLException
Releases all local resources held by this Statement. Closes any associated ResultSet, which may cause a CLOSE CURSOR to be executed.

Specified by:
close in interface java.sql.Statement
Throws:
java.sql.SQLException - not really.

execute

public boolean execute(java.lang.String sql)
                throws java.sql.SQLException
Execute a SQL statement that may return multiple results. Starting with CA IDMS r17, a procedure may return one or more result sets. CA IDMS never returns more than a single update count.

Specified by:
execute in interface java.sql.Statement
Parameters:
sql - SQL statement
Returns:
true if there is a ResultSet; false if an update count or there are no result sets
Throws:
java.sql.SQLException - if an error occurs.
See Also:
getResultSet(), getUpdateCount(), getMoreResults()

executeQuery

public java.sql.ResultSet executeQuery(java.lang.String sql)
                                throws java.sql.SQLException
Execute a SQL statement that returns a single ResultSet. Normally this is a SELECT statement. Starting with CA IDMS r17 this can be a CALL statement that invokes a procedure that returns exactly one result set.

Specified by:
executeQuery in interface java.sql.Statement
Parameters:
sql - an SQL SELECT or CALL statement
Returns:
the result set, never null
Throws:
java.sql.SQLException - if an error occurs or the statement does not return exactly one result set.

executeUpdate

public int executeUpdate(java.lang.String sql)
                  throws java.sql.SQLException
Execute a SQL INSERT, UPDATE or DELETE statement. SQL statements that return nothing such as SQL DDL statements can be executed. SQL CALL statements can also be executed, but there are no methods to retreive the output parameters in this class.

Specified by:
executeUpdate in interface java.sql.Statement
Parameters:
sql - the SQL statement syntax
Returns:
either the row count for INSERT, UPDATE or DELETE or 0 for DDL or CALL statements.
Throws:
java.sql.SQLException - if a database-access error occurs.

getResultSet

public java.sql.ResultSet getResultSet()
                                throws java.sql.SQLException
Returns the current result as a ResultSet. This method should only be called once per result.

Specified by:
getResultSet in interface java.sql.Statement
Returns:
the current result as a ResultSet; null if the result is an update count or there are no more results
Throws:
java.sql.SQLException - if a database-access error occurs.
See Also:
execute(java.lang.String), executeQuery(java.lang.String)

getUpdateCount

public int getUpdateCount()
                   throws java.sql.SQLException
Returns the current result as an update count. If the result is a ResultSet or there are no more results, -1 is returned. It should only be called once per result.

Specified by:
getUpdateCount in interface java.sql.Statement
Returns:
the update count or -1
Throws:
java.sql.SQLException - if an error occurs.
See Also:
#see #executeUpdate

getMoreResults

public boolean getMoreResults()
                       throws java.sql.SQLException
Moves to the "next" ResultSet. This method is equivalent to getMoreResults(CLOSE_CURRENT_RESULT), that is, it will close the current ResultSet, if any.

Specified by:
getMoreResults in interface java.sql.Statement
Returns:
false if an update count or there are no more results
Throws:
java.sql.SQLException - if an error occurs.

getMaxFieldSize

public int getMaxFieldSize()
                    throws java.sql.SQLException
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. If the limit is exceeded, the excess data is silently discarded.

Specified by:
getMaxFieldSize in interface java.sql.Statement
Returns:
the current max column size limit; zero means unlimited
Throws:
java.sql.SQLException - not!

setMaxFieldSize

public void setMaxFieldSize(int max)
                     throws java.sql.SQLException
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. If the limit is exceeded, the excess data is silently discarded. For maximum portability use values greater than 256.

Specified by:
setMaxFieldSize in interface java.sql.Statement
Parameters:
max - the new max column size limit; zero means unlimited
Throws:
java.sql.SQLException - not!

getMaxRows

public int getMaxRows()
               throws java.sql.SQLException
The maxRows limit is the maximum number of rows that a ResultSet can contain. If the limit is exceeded, the excess rows are silently dropped.

Specified by:
getMaxRows in interface java.sql.Statement
Returns:
the current max row limit; zero means unlimited
Throws:
java.sql.SQLException - not!

setMaxRows

public void setMaxRows(int max)
                throws java.sql.SQLException
The maxRows limit is set to limit the number of rows that any ResultSet can contain. If the limit is exceeded, the excess rows are silently dropped.

Specified by:
setMaxRows in interface java.sql.Statement
Parameters:
max - the new max rows limit; zero means unlimited
Throws:
java.sql.SQLException - not!

setEscapeProcessing

public void setEscapeProcessing(boolean enable)
                         throws java.sql.SQLException
If escape scanning is on (the default), the driver will do escape substitution before sending the SQL to the database. Note: Although the IDMS JDBC driver defers actually preparing statements until they are executed the first time, syntax is scanned and converted when a PreparedStatement is created, so disabling escape processing for prepared statements has no affect.

Specified by:
setEscapeProcessing in interface java.sql.Statement
Parameters:
enable - true to enable; false to disable
Throws:
java.sql.SQLException - not really.

getQueryTimeout

public int getQueryTimeout()
                    throws java.sql.SQLException
Gets the reply timeout for this IdmsStatement object.

Specified by:
getQueryTimeout in interface java.sql.Statement
Returns:
the current query timeout limit in seconds; zero means unlimited
Throws:
java.sql.SQLException - not!
See Also:
setQueryTimeout(int)

setQueryTimeout

public void setQueryTimeout(int seconds)
                     throws java.sql.SQLException
Sets the reply timeout for this Statement object. The value limits how long the driver will wait for a reply from the server for any method invoked on this statement object or and result sets it creates. If the limit is exceeded, an SQLException is thrown.

Specified by:
setQueryTimeout in interface java.sql.Statement
Parameters:
seconds - the new query timeout limit in seconds; zero means unlimited
Throws:
java.sql.SQLException - if seconds < 0

setCursorName

public void setCursorName(java.lang.String s)
                   throws java.sql.SQLException
Defines a cursor name to use for positioned updates and deletes. When a cursor name is set, an internally generated extended statement name is used to PREPARE the SQL query, an ALLOCATE CURSOR command is executed to associate the cursor name with the prepared statement, and an OPEN is explicitly issued (it is not piggybacked onto the PREPARE). If the statement was already prepared with a static name to satisfy a result set or parameter metadata request it will be prepared again with an extended name before execution. The size of the FETCH buffer will be set to 1 so that the cursor postion will be as expected for positioned updates and deletes.

This method does nothing if the CA IDMS system is prior to Release 14.0, since dynamic positioned updates and deletes are not supported.

Specified by:
setCursorName in interface java.sql.Statement
Parameters:
s - the new extended cursor name.
Throws:
java.sql.SQLException - if a cursor name in is not unique.

getConnection

public java.sql.Connection getConnection()
                                  throws java.sql.SQLException
Gets the Connection.

Specified by:
getConnection in interface java.sql.Statement
Returns:
the IdmsConnection object
Throws:
java.sql.SQLException - never
Since:
1.2

getResultSetType

public int getResultSetType()
                     throws java.sql.SQLException
Gets the ResultSet type.

Specified by:
getResultSetType in interface java.sql.Statement
Returns:
ResultSet.TYPE_FORWARD_ONLY or ResultSet.TYPE_SCROLL_INSENSITIVE.
Throws:
java.sql.SQLException - never
Since:
1.2

getResultSetConcurrency

public int getResultSetConcurrency()
                            throws java.sql.SQLException
Gets the ResultSet concurrency.

Specified by:
getResultSetConcurrency in interface java.sql.Statement
Returns:
ResultSet.CONCUR_READ_ONLY.
Throws:
java.sql.SQLException - never
Since:
1.2

getGeneratedKeys

public java.sql.ResultSet getGeneratedKeys()
                                    throws java.sql.SQLException
CA IDMS does not support automatically generated keys.

Specified by:
getGeneratedKeys in interface java.sql.Statement
Returns:
an empty ResultSet
Throws:
java.sql.SQLException - never
Since:
1.4

getResultSetHoldability

public int getResultSetHoldability()
                            throws java.sql.SQLException
For CA IDMS ResultSet holdability is a Connection attribute.

Specified by:
getResultSetHoldability in interface java.sql.Statement
Returns:
the holdability set for the connection.
Throws:
java.sql.SQLException - not really
Since:
1.4
See Also:
IdmsConnection.getHoldability(), IdmsConnection.getHoldability()

execute

public boolean execute(java.lang.String sql,
                       int key)
                throws java.sql.SQLException
Executes an IDMS statement. IDMS does not support auto generated keys, so this method is equivalent to execute(String).

Specified by:
execute in interface java.sql.Statement
Parameters:
sql - SQL statement
key - auto generated key flag, ignored
Returns:
the prepared statement object
Throws:
java.sql.SQLException - if an error occurs
Since:
1.4
See Also:
getGeneratedKeys()

execute

public boolean execute(java.lang.String sql,
                       int[] index)
                throws java.sql.SQLException
Executes an IDMS statement. IDMS does not support auto generated keys, so this method is equivalent to execute(String).

Specified by:
execute in interface java.sql.Statement
Parameters:
sql - SQL statement
index - auto generated ordinals array, ignored
Returns:
the prepared statement object
Throws:
java.sql.SQLException - if an error occurs
Since:
1.4
See Also:
getGeneratedKeys()

execute

public boolean execute(java.lang.String sql,
                       java.lang.String[] names)
                throws java.sql.SQLException
Executes an IDMS statement. IDMS does not support auto generated keys, so this method is equivalent to execute(String).

Specified by:
execute in interface java.sql.Statement
Parameters:
sql - SQL statement
names - auto generated names array, ignored
Returns:
the prepared statement object
Throws:
java.sql.SQLException - if an error occurs
Since:
1.4
See Also:
getGeneratedKeys()

executeUpdate

public int executeUpdate(java.lang.String sql,
                         int key)
                  throws java.sql.SQLException
Executes an IDMS update statement. IDMS does not support auto generated keys, so this method is equivalent to executeUpdate(String).

Specified by:
executeUpdate in interface java.sql.Statement
Parameters:
sql - SQL statement
key - auto generated key flag, ignored
Returns:
the prepared statement object
Throws:
java.sql.SQLException - if an error occurs
Since:
1.4
See Also:
getGeneratedKeys()

executeUpdate

public int executeUpdate(java.lang.String sql,
                         int[] index)
                  throws java.sql.SQLException
Executes an IDMS update statement. IDMS does not support auto generated keys, so this method is equivalent to executeUpdate(String).

Specified by:
executeUpdate in interface java.sql.Statement
Parameters:
sql - SQL statement
index - auto generated ordinals array, ignored
Returns:
the prepared statement object
Throws:
java.sql.SQLException - if an error occurs
Since:
1.4
See Also:
getGeneratedKeys()

executeUpdate

public int executeUpdate(java.lang.String sql,
                         java.lang.String[] names)
                  throws java.sql.SQLException
Executes an IDMS update statement. IDMS does not support auto generated keys, so this method is equivalent to executeUpdate(String).

Specified by:
executeUpdate in interface java.sql.Statement
Parameters:
sql - SQL statement
names - auto generated names array, ignored
Returns:
the prepared statement object
Throws:
java.sql.SQLException - if an error occurs
Since:
1.4
See Also:
getGeneratedKeys()

isPoolable

public boolean isPoolable()
                   throws java.sql.SQLException
Returns a value indicating whether or not the Statement should be pooled by a connection pool manager. The default for a Statement is false; the default for a PreparedStatement or CallableStatement is true.

Specified by:
isPoolable in interface java.sql.Statement
Returns:
true if the Statement is poolable; false otherwise
Throws:
java.sql.SQLException - - if this method is called on a closed Statement
Since:
1.6

setPoolable

public void setPoolable(boolean enable)
                 throws java.sql.SQLException
Allows an application to set a hint to the connection pool manager as to whether a statement should be pooled or not.

Specified by:
setPoolable in interface java.sql.Statement
Parameters:
enable - true to allow a statement to be pooled; false otherwise
Throws:
java.sql.SQLException
Since:
1.6

addBatch

public void addBatch(java.lang.String sql)
              throws java.sql.SQLException
Adds an SQL statement to the list of batch updates. The SQL statement can be a DDL statement or an INSERT, UPDATE, DELETE statement with no parameters. The statement is not validated until executeBatch() is invoked.

Specified by:
addBatch in interface java.sql.Statement
Parameters:
sql - the update command.
Throws:
java.sql.SQLException - not really
Since:
16.0

clearBatch

public void clearBatch()
                throws java.sql.SQLException
Clears the list of batch updates.

Specified by:
clearBatch in interface java.sql.Statement
Throws:
java.sql.SQLException - never
Since:
16.0

executeBatch

public int[] executeBatch()
                   throws java.sql.SQLException
Executes the current set of batch updates. The driver continues execution of the batch after an error occurs executing a statement. If autoCommit is enabled it is done on the last statement of the batch, whether errors occurred or not.

This method is supported for J2EE compatibility and convenience. Each statement in the batch is sent separately to the database, so the performance advantage is limited to ending the IDMS-DC task (pseudo converse) at the end of the batch instead of after each statement when autoCommit is enabled. The IdmsPreparedStatement.executeBatch() uses the bulk feature to enhance performance for INSERT commands.

Specified by:
executeBatch in interface java.sql.Statement
Returns:
complete array of update counts
Throws:
java.sql.SQLException - if not connected or the batch is empty
java.sql.BatchUpdateException - if an error occurs processing a statement
Since:
16.0

getMoreResults

public boolean getMoreResults(int current)
                       throws java.sql.SQLException
Moves to the "next" ResultSet, disposing of any open ones as specified Starting with CA IDMS r17, multiple results are supported.

Specified by:
getMoreResults in interface java.sql.Statement
Parameters:
current - indicates what should happen to the current ResultSet
Returns:
true if there is another result set, false otherwise
Throws:
java.sql.SQLException - if an error occurs.
Since:
1.4


Copyright © 2009 CA, All rights reserved