public class ESQLProcessor extends java.lang.Object implements SQLHandlerInterface
sqlProcessor.prepare("SELECT name FROM customer-table WHERE id > ?"); // Bind output variables for embedded sql sqlProcessor.setInParameter(1, iData.getId()); sqlProcessor.setOutParameter(1, iData.getFieldName()); sqlProcessor.executeQuery(); // or sqlProcessor.openCursor() while (sqlProcessor.next()( { System.out.println( idata.getName() ); }or
sqlProcessor.prepare("INSERT INTO customer-table VALUES ( ? , ? )"); // Bind output variables for embedded sql sqlProcessor.setInParameter(1, iData.getId()); sqlProcessor.setInParameter(2, iData.getName()); sqlProcessor.executeUpdate();
Modifier and Type | Field and Description |
---|---|
protected java.sql.Connection |
connection
Connection to the database
|
protected java.lang.String |
lastQuery |
protected static Log |
logger |
protected java.sql.PreparedStatement |
preparedStatement |
static long |
totalRuntime
for internal use only ...
|
static long |
totalRuntime_prepareFromFile |
HANDLER_CONTINUE, HANDLER_GO_TO, HANDLER_METHOD_CALL, HANDLER_NOT_INTIALIZED, HANDLER_PERFORM, HANDLER_STOP, HANDLER_THROW, SQL_SCHEMA_PROP
Constructor and Description |
---|
ESQLProcessor(ESQLBaseService owner)
Constructor
|
ESQLProcessor(ESQLBaseService owner,
ISMBean sqlca)
constructor -
|
ESQLProcessor(ESQLBaseService owner,
ISMBean sqlca,
ESQLProcessor shareConnection)
Deprecated.
|
Modifier and Type | Method and Description |
---|---|
protected void |
assignOutParameter(ISMObject outParameter,
java.lang.Object rsData)
transfer a value from ResultSet to the ACMObject
|
void |
clearOutParameters()
clear the previously assigned output-parameters, allowing new output-parameters to be assigned.
|
int |
close()
CLose underlying resultset
|
void |
commit()
This method uses the commit method on java.sql.Connection.
|
protected void |
createPreparedStatement(java.lang.String sql,
boolean isForUpdate) |
void |
deleteRow()
delete the current row
|
int |
executeQuery()
Execute SQL Query.
|
int |
executeUpdate()
Execute SQL Query.
|
int |
executeUpdateThrowingSQLExpeption()
Not used by translator.
|
int |
fetch()
do fetch 'next' in the underlying resultset with SQL return codes
|
void |
forceCommit()
When auto-commit is not used, this method will force a connection.commit() - whether the system is using BATCH processing or not.
|
void |
forceRollback()
When auto-commit is not used, this method will force a connection.rollback() - whether the system is using BATCH processing or not.
|
protected java.lang.String |
formatSQL(java.lang.String theSql)
This method is intended to be overridden.
|
java.sql.Connection |
getConnection()
get connection from connectionFactory
|
java.lang.String |
getDbPropertiesURI()
get URI to db.properties file.
|
protected ESQLBaseService |
getESQLBaseService() |
java.sql.PreparedStatement |
getPreparedStatement() |
java.sql.ResultSet |
getResultset() |
int |
getRowCount() |
ISMBean |
getSQLCA() |
boolean |
isStatusAfterEndOfResultset() |
boolean |
isStatusCursorNotOpenError() |
boolean |
isStatusDuplicateInsert() |
boolean |
isStatusError() |
boolean |
isStatusMultipleEntries() |
boolean |
isStatusNoEntry() |
boolean |
isStatusNormal() |
boolean |
isStatusNullReturn() |
boolean |
isStatusOpenCloseError() |
boolean |
isStatusTimeout() |
boolean |
isStatusTimeoutNoTimeout() |
int |
next()
do 'next' in the underlying resultset
|
boolean |
nextRow()
do 'next' in the underlying resultset
|
int |
openCursor()
Execute SQL Query.
|
void |
prepare(java.lang.String sql)
prepare the underlying 'statement' or 'preparedStatement'
|
void |
prepare(java.lang.String sql,
boolean isForUpdate)
prepare the underlying 'statement' or 'preparedStatement'
|
protected void |
prepareHelper(java.lang.String sql)
prepare the underlying 'statement' or 'preparedStatement'
|
void |
prepareSQLFromFile(java.lang.String fileName)
Allows externalization of SQL scripts.
|
void |
prepareSQLFromFile(java.lang.String fileName,
boolean isForUpdate)
Allows externalization of SQL scripts.
|
protected int |
processSQLException(java.sql.SQLException e,
ISMBean sqlca,
boolean afterEndOfResultset)
Sets the appropriate values on SQLCA
|
protected int |
processSQLException(java.sql.SQLException e,
ISMBean sqlca,
int theRowCount)
Sets the appropriate values on SQLCA
|
void |
releaseConnection()
CloseConnection is used internally
on destroy of the application
|
void |
releaseResources(boolean releaseConnection)
close connection, and set owning ESQLBaseService to Null - for improved GC
|
protected void |
resetSqlca()
Assign appropriate (normal return) values to SQLCA
|
void |
rollback()
rollback the sql
Only works when AUTO-COMMIT is switched off in db.properties. |
void |
setBatchSize(int batchSize)
setting a batch size of greater than one will cause the method executeUpdate to
preparedStatement.addBatch() instead of preparedStatement.executeUpdate() |
void |
setClearOutParametersOnGet(boolean newValue)
By-default, the system will NOT clear the OutputParameters after a executeQuery/OpenCursor/Fetch/Next
This method allows the developers to override the functionality -
|
void |
setConnection(java.sql.Connection connection) |
void |
setDbPropertiesURI(java.lang.String dbPropertiesURI) |
void |
setFetchSize(int newFetchSize)
maps onto ResultSet.setFetchSize
Gives the JDBC driver a hint as to the number of rows that should be fetched from the
database when more rows are needed for this ResultSet object.
|
void |
setInParameter(int position,
java.math.BigDecimal value)
Set input parameters for prepared query
|
void |
setInParameter(int position,
java.math.BigDecimal newValue,
int nullIndicator)
Set input parameters for prepared SQL query containing INSERT/UPDATE, and take account of Null indicator.
|
void |
setInParameter(int position,
byte[] value)
Set input parameters for prepared query
|
void |
setInParameter(int position,
CBLBean valueHolder) |
void |
setInParameter(int position,
java.util.Date value)
Set input parameters for prepared query
|
void |
setInParameter(int position,
double value)
Set input parameters for prepared query
|
void |
setInParameter(int position,
double newValue,
int nullIndicator)
Set input parameters for prepared SQL query containing INSERT/UPDATE, and take account of Null indicator.
|
void |
setInParameter(int position,
int value)
Set input parameters for prepared query
|
void |
setInParameter(int position,
ISMBean valueHolder,
ISMInteger nullIndicator)
Set input parameters for prepared SQL query containing INSERT/UPDATE, and take account of Null indicator.
|
void |
setInParameter(int position,
ISMDataType valueHolder)
Set input parameters for prepared SQL query containing INSERT/UPDATE
|
void |
setInParameter(int position,
ISMObject valueHolder,
ISMInteger nullIndicator)
Set input parameters for prepared SQL query containing INSERT/UPDATE, and take account of Null indicator.
|
void |
setInParameter(int position,
long value)
Set input parameters for prepared query
|
void |
setInParameter(int position,
java.lang.String value)
Set input parameters for prepared query
|
void |
setInParameter(int position,
java.lang.String value,
int nullIndicator)
Set input parameters for prepared SQL query containing INSERT/UPDATE, and take account of Null indicator.
|
void |
setInParameter(int position,
java.lang.String value,
ISMInteger nullIndicator)
Set input parameters for prepared SQL query containing INSERT/UPDATE, and take account of Null indicator.
|
void |
setInParameterOn49Group(int position,
CBLBean wrapper)
Special case for setting Output parameters for DB2 - 49 Level groups
For more information see the java-doc for setInParameterOn49Group(int position, ISMGroup valueHolder)
|
void |
setInParameterOn49Group(int position,
ISMGroup group)
Special case for setting Output parameters for DB2 - 49 Level groups
For more information see the java-doc for setInParameterOn49Group(int position, ISMGroup valueHolder)
|
void |
setInParameterOn49Group(int position,
ISMGroup group,
ISMInteger nullIndicator)
Special case for set input parameters for prepared query
For more information see the java-doc for setOutParameterOn49Group(int position, ISMGroup valueHolder)
|
void |
setOutParameter(int position,
CBLBean wrapper)
Bind output input parameters for prepared query
|
void |
setOutParameter(int position,
ISMDataType valueHolder)
Bind output input parameters for prepared query
|
void |
setOutParameter(int position,
ISMDataType valueHolder,
ISMDataType nullIndicator)
Bind output input parameters for prepared query
|
void |
setOutParameterOn49Group(int position,
CBLBean wrapper)
Special case for setting Output parameters for DB2 - 49 Level groups
For more information see the java-doc for setOutParameterOn49Group(int position, ISMGroup valueHolder)
|
void |
setOutParameterOn49Group(int position,
ISMBean bean,
ISMObject nullIndicator)
Special case for setting Output parameters for DB2 - 49 Level groups
For more information see the java-doc for setOutParameterOn49Group(int position, ISMGroup valueHolder)
|
void |
setOutParameterOn49Group(int position,
ISMGroup valueHolder)
Special case for set Output parameters for prepared query
DB2 VARCHAR's can be declared in COBOL as a field, or as group items containing only two elementary items,
both of which must have a level number of 49.
|
void |
setOutParameterOn49Group(int position,
ISMGroup valueHolder,
ISMObject nullIndicator)
Special case for setting Output parameters for DB2 - 49 Level groups
For more information see the java-doc for setOutParameterOn49Group(int position, ISMGroup valueHolder)
|
void |
setSQLCA(ISMBean sqlca)
Associated return values with the SQLCA file.
|
void |
setWithHold()
Deprecated.
|
void |
updateColumnValue(int columnIndex,
double value)
Used in db2's SELECT col1 From table FOR UPDATE
first the system will do cursor.executeQuery() later it can do cursor.updateColumnValue(1, newValue); cursor.updateRow(); in this example, the value of "col1" will be updated |
void |
updateColumnValue(int columnIndex,
int value)
Used in db2's SELECT col1 From table FOR UPDATE
first the system will do cursor.executeQuery() later it can do cursor.updateColumnValue(1, newValue); cursor.updateRow(); in this example, the value of "col1" will be updated |
void |
updateColumnValue(int columnIndex,
ISMDouble valueObj)
Used in db2's SELECT col1 From table FOR UPDATE
first the system will do cursor.executeQuery() later it can do cursor.updateColumnValue(1, newValue); in this example, the value of "col1" will be updated |
void |
updateColumnValue(int columnIndex,
ISMGroup theContainer) |
void |
updateColumnValue(int columnIndex,
ISMInteger valueObj)
Used in db2's SELECT col1 From table FOR UPDATE
first the system will do cursor.executeQuery() later it can do cursor.updateColumnValue(1, newValue); cursor.updateRow(); in this example, the value of "col1" will be updated |
void |
updateColumnValue(int columnIndex,
ISMLong valueObj)
Used in db2's SELECT col1 From table FOR UPDATE
first the system will do cursor.executeQuery() later it can do cursor.updateColumnValue(1, newValue); cursor.updateRow(); in this example, the value of "col1" will be updated |
void |
updateColumnValue(int columnIndex,
ISMString valueObj)
Used in db2's SELECT col1 From table FOR UPDATE
first the system will do cursor.executeQuery() later it can do cursor.updateColumnValue(1, newValue); cursor.updateRow(); in this example, the value of "col1" will be updated |
void |
updateColumnValue(int columnIndex,
long value)
Used in db2's SELECT col1 From table FOR UPDATE
first the system will do cursor.executeQuery() later it can do cursor.updateColumnValue(1, newValue); cursor.updateRow(); in this example, the value of "col1" will be updated |
void |
updateColumnValue(int columnIndex,
java.lang.String value)
Used in db2's SELECT col1 From table FOR UPDATE
first the system will do cursor.executeQuery() later it can do cursor.updateColumnValue(1, newValue); cursor.updateRow(); in this example, the value of "col1" will be updated |
void |
updateRow()
Used in db2's SELECT col1 From table FOR UPDATE
first the system will do cursor.executeQuery() later it can do cursor.updateColumnValue(1, newValue); cursor.updateRow(); in this example, the value of "col1" will be updated |
protected java.sql.Connection connection
protected java.sql.PreparedStatement preparedStatement
protected java.lang.String lastQuery
protected static Log logger
public static long totalRuntime
public static long totalRuntime_prepareFromFile
public ESQLProcessor(ESQLBaseService owner)
owner
- public ESQLProcessor(ESQLBaseService owner, ISMBean sqlca)
owner
- sqlca
- public ESQLProcessor(ESQLBaseService owner, ISMBean sqlca, ESQLProcessor shareConnection)
owner
- program that owns the created ESQLProcessorsqlca
- SQLCA member that will be used to write the SQL Codes, Errors, and WarningsshareConnection
- ESQLProcessor that should be used to seed the connection for this
ESQLProcessor, both will execute on the same connection to the databasepublic void setSQLCA(ISMBean sqlca)
sqlca
- public void prepare(java.lang.String sql) throws CBLException
sql
- CBLException
public void prepare(java.lang.String sql, boolean isForUpdate) throws CBLException
sql
- isForUpdate
- : true when used for SELECT ... FOR UPDATE OF Cursor-nameCBLException
protected void prepareHelper(java.lang.String sql) throws CBLException
sql
- isForUpdate
- : true when used for SELECT ... FOR UPDATE OF Cursor-nameCBLException
@Deprecated public void setWithHold()
protected void createPreparedStatement(java.lang.String sql, boolean isForUpdate) throws java.sql.SQLException
java.sql.SQLException
protected void assignOutParameter(ISMObject outParameter, java.lang.Object rsData)
outParameter
- rsData
- public int openCursor() throws CBLException
CBLException
public int executeQuery() throws CBLException
CBLException
public int executeUpdate() throws CBLException
CBLException
public void setBatchSize(int batchSize)
public int executeUpdateThrowingSQLExpeption() throws java.sql.SQLException
java.sql.SQLException
public int next() throws CBLException
CBLException
public boolean nextRow() throws CBLException
CBLException
public int fetch() throws CBLException
CBLException
public int close() throws CBLException
CBLException
public void clearOutParameters()
public void setInParameter(int position, ISMDataType valueHolder)
public void setInParameter(int position, ISMObject valueHolder, ISMInteger nullIndicator)
position
- intvalueHolder
- ACMObjectnullIndicator
- ACMObjectpublic void setInParameterOn49Group(int position, CBLBean wrapper)
public void setInParameterOn49Group(int position, ISMGroup group)
public void setInParameterOn49Group(int position, ISMGroup group, ISMInteger nullIndicator)
public void setInParameter(int position, int value)
position
- intvalue
- Integerpublic void setInParameter(int position, long value)
position
- intvalue
- Integerpublic void setInParameter(int position, java.lang.String value)
position
- intvalue
- Integerpublic void setInParameter(int position, byte[] value)
public void setInParameter(int position, java.lang.String value, ISMInteger nullIndicator)
public void setInParameter(int position, java.lang.String value, int nullIndicator)
public void setInParameter(int position, double newValue, int nullIndicator)
public void setInParameter(int position, java.math.BigDecimal newValue, int nullIndicator)
public void setInParameter(int position, java.util.Date value)
position
- intvalue
- Integerpublic void setInParameter(int position, double value)
public void setInParameter(int position, java.math.BigDecimal value)
public void setInParameter(int position, CBLBean valueHolder)
public void setInParameter(int position, ISMBean valueHolder, ISMInteger nullIndicator)
public void setOutParameter(int position, ISMDataType valueHolder)
position
- intvalueHolder
- ACMObjectpublic void setOutParameter(int position, CBLBean wrapper)
position
- intwrapper
- ISMBean - setOutParameter(position, wrapper.getTopLevelField())public void setOutParameter(int position, ISMDataType valueHolder, ISMDataType nullIndicator)
position
- intvalueHolder
- ACMObjectnull
- Indicator ACMObjectpublic void setOutParameterOn49Group(int position, ISMGroup valueHolder)
position
- intvalueHolder
- ISMGroup representing a 49 level Element with 2 fields, 1 numeric and one Stringpublic void setOutParameterOn49Group(int position, CBLBean wrapper)
public void setOutParameterOn49Group(int position, ISMGroup valueHolder, ISMObject nullIndicator)
public void setOutParameterOn49Group(int position, ISMBean bean, ISMObject nullIndicator)
protected ESQLBaseService getESQLBaseService()
public void releaseResources(boolean releaseConnection)
public java.sql.Connection getConnection()
public void setConnection(java.sql.Connection connection)
public void releaseConnection()
protected int processSQLException(java.sql.SQLException e, ISMBean sqlca, boolean afterEndOfResultset) throws CBLException
e
- sqlca
- afterEndOfResultset
- CBLException
protected int processSQLException(java.sql.SQLException e, ISMBean sqlca, int theRowCount) throws CBLException
e
- sqlca
- theRowCount
- CBLException
public int getRowCount()
public void commit()
public void forceCommit()
public void rollback()
sqlprocessor.prepare("ROLLBACK"); sqlprocessor.executeUpdate();The method uses the Rollback method on java.sql.Connection. Therefore ALL THE SQL statements which have used this connection will get Rolled back .
public void forceRollback()
public ISMBean getSQLCA()
public java.lang.String getDbPropertiesURI()
public void setDbPropertiesURI(java.lang.String dbPropertiesURI)
public void prepareSQLFromFile(java.lang.String fileName)
fileName
- public void prepareSQLFromFile(java.lang.String fileName, boolean isForUpdate)
fileName
- isForUpdate
- : true when used for SELECT ... FOR UPDATE OF Cursor-nameprotected java.lang.String formatSQL(java.lang.String theSql)
protected void resetSqlca()
public void setClearOutParametersOnGet(boolean newValue)
public void setFetchSize(int newFetchSize)
public void deleteRow()
public java.sql.ResultSet getResultset()
public void updateRow()
public void updateColumnValue(int columnIndex, java.lang.String value)
public void updateColumnValue(int columnIndex, ISMGroup theContainer)
public void updateColumnValue(int columnIndex, int value)
public void updateColumnValue(int columnIndex, double value)
public void updateColumnValue(int columnIndex, long value)
public void updateColumnValue(int columnIndex, ISMString valueObj)
public void updateColumnValue(int columnIndex, ISMDouble valueObj)
public void updateColumnValue(int columnIndex, ISMInteger valueObj)
public void updateColumnValue(int columnIndex, ISMLong valueObj)
public java.sql.PreparedStatement getPreparedStatement()
public boolean isStatusNormal()
public boolean isStatusNullReturn()
public boolean isStatusDuplicateInsert()
public boolean isStatusMultipleEntries()
public boolean isStatusTimeout()
public boolean isStatusTimeoutNoTimeout()
public boolean isStatusError()
public boolean isStatusOpenCloseError()
public boolean isStatusCursorNotOpenError()
public boolean isStatusNoEntry()
public boolean isStatusAfterEndOfResultset()
Copyright SoftwareMining. All Rights Reserved.