Copyright 2009,2010, Lapetus Systems Ltd. (All rights reserved)

com.lapetus_ltd.api.db.control
Class TLptsStatement

java.lang.Object
  extended by com.lapetus_ltd._2009.xml.types.XLptsDBStatementType
      extended by com.lapetus_ltd.api.db.control.TLptsStatement
All Implemented Interfaces:
java.sql.Statement, java.sql.Wrapper

public class TLptsStatement
extends XLptsDBStatementType
implements java.sql.Statement

Class Description : This is the statement class that implements the java.sql.Statement interface.

The TLptsStatement class extends the XLptsDBStatementType so that the data in this class can be stored in a
XML structure for storage or transportation.
This class can be created before the java.sql.Statement object (like PrepareStatement) is created. It therefore
allows for the settings or retrieval of settings within this class and then processing of the Statement.


$LastChangedRevision: 1225 $
$LastChangedDate:: 2010-12-06 09:47:57#$


Field Summary
 
Fields inherited from class com.lapetus_ltd._2009.xml.types.XLptsDBStatementType
charset, columnListItem, connectionId, createRootItem, criteriaType, executable, id, sqlDatabaseFormat, sqlStatementExtension, sqlStatementModified, sqlStatementUnformatted, sqlStatementUser, sqlStringFormat, tableListItem, tableTypesView, title, typeOfStatement, upInsDelListItem, version, visible, xResultSetConcurrency, xResultSetType
 
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
TLptsStatement(TLptsConnection connection, XLptsDBStatementType statementType)
          This Constructor create a new Statement by setting only the connection and loading all the fields from another Statement.
TLptsStatement(TLptsConnection connection, XLptsDBTypeOfStatementType typeOfStatement)
          Creates a new Statement by setting the connection and the type of the statement.
 
Method Summary
 void addBatch(java.lang.String sql)
          Javadoc taken from Statement interface : Adds the given SQL command to the current list of commmands for this Statement object.
 void addPrimaryRelationship(int localColumnIndex, int[] foreignColumnIndexes, java.lang.String operation)
          Adds a primary relationship of the current statement with the primary statement.
 void cancel()
          Javadoc taken from Statement interface : Cancels this Statement object if both the DBMS and driver support aborting an SQL statement.
 void clearBatch()
          Javadoc taken from Statement interface : Empties this Statement object's current list of SQL commands.
 void clearWarnings()
          Javadoc taken from Statement interface : Clears all the warnings reported on this Statement object.
 void close()
          Javadoc taken from Statement interface : Releases this Statement object's database and JDBC resources immediately instead of waiting for this to happen when it is automatically closed.
 boolean closeWE()
           Close current statement.
 boolean equals(java.lang.Object obj)
          Compares the objects by their ID.
 boolean execute(java.lang.String sql)
          Javadoc taken from Statement interface : Executes the given SQL statement, which may return multiple results.
 boolean execute(java.lang.String sql, int autoGeneratedKeys)
          Javadoc taken from Statement interface : Executes the given SQL statement, which may return multiple results, and signals the driver that any auto-generated keys should be made available for retrieval.
 boolean execute(java.lang.String sql, int[] columnIndexes)
          Javadoc taken from Statement interface : Executes the given SQL statement, which may return multiple results, and signals the driver that the auto-generated keys indicated in the given array should be made available for retrieval.
 boolean execute(java.lang.String sql, java.lang.String[] columnNames)
          Javadoc taken from Statement interface : Executes the given SQL statement, which may return multiple results, and signals the driver that the auto-generated keys indicated in the given array should be made available for retrieval.
 int[] executeBatch()
          Javadoc taken from Statement interface : Submits a batch of commands to the database for execution and if all commands execute successfully, returns an array of update counts.
 java.sql.ResultSet executeQuery()
          Executes the query of the selected statement.
 java.sql.ResultSet executeQuery(java.lang.String sql)
          Javadoc taken from Statement interface : Executes the given SQL statement, which returns a single ResultSet object.
 int executeUpdate()
          Executes an Update on a PreparedStatement.
 int executeUpdate(java.lang.String sql)
          Javadoc taken from Statement interface : Executes the given SQL statement, which may be an INSERT, UPDATE, or DELETE statement or an SQL statement that returns nothing, such as an SQL DDL statement.
 int executeUpdate(java.lang.String sql, int autoGeneratedKeys)
          Javadoc taken from Statement interface : Executes the given SQL statement and signals the driver with the given flag about whether the auto-generated keys produced by this Statement object should be made available for retrieval.
 int executeUpdate(java.lang.String sql, int[] columnIndexes)
          Javadoc taken from Statement interface : Executes the given SQL statement and signals the driver that the auto-generated keys indicated in the given array should be made available for retrieval.
 int executeUpdate(java.lang.String sql, java.lang.String[] columnNames)
          Javadoc taken from Statement interface : Executes the given SQL statement and signals the driver that the auto-generated keys indicated in the given array should be made available for retrieval.
 TLptsStatement findTopPrimaryStatement()
          Gets the top primary statement (level 1).
 java.util.List<java.lang.Integer> geSelectedColumnSqlTypeList()
          Gets a list of SQL types for the currently selected columns of this statement.
 XLptsDBStatementColumnType getColumnItemById(java.lang.String id)
          Gets a column by it's ID.
 XLptsDBStatementColumnType getColumnItemByName(java.lang.String tableName, java.lang.String columnName)
          Gets a column by it's name and table name.
 java.util.List<XLptsDBStatementColumnType> getColumnItemsForTable(java.lang.String tableName)
           Gets a list with all the columns for a table.
 java.util.List<XLptsDBStatementColumnType> getColumnListItem()
          Gets a copy of the actual list of all columns from current datasource.
 java.sql.Connection getConnection()
          Javadoc taken from Statement interface : Retrieves the Connection object (TLptsConnection) that produced this Statement object.
 java.sql.Connection getConnectionWE()
           Retrieves the Connection object (TLptsConnection) that produced this Statement object.
 int getFetchDirection()
          Javadoc taken from Statement interface : Retrieves the direction for fetching rows from database tables that is the default for result sets generated from this Statement object.
 int getFetchSize()
          Javadoc taken from Statement interface : Retrieves the number of result set rows that is the default fetch size for ResultSet objects generated from this Statement object.
 java.sql.ResultSet getGeneratedKeys()
          Javadoc taken from Statement interface : Retrieves any auto-generated keys created as a result of executing this Statement object.
 int getMaxFieldSize()
          Javadoc taken from Statement interface : Retrieves the maximum number of bytes that can be returned for character and binary column values in a ResultSet object produced by this Statement object.
 int getMaxRows()
          Javadoc taken from Statement interface : Retrieves the maximum number of rows that a ResultSet object produced by this Statement object can contain.
 boolean getMoreResults()
          Javadoc taken from Statement interface : Moves to this Statement object's next result, returns true if it is a ResultSet object, and implicitly closes any current ResultSet object(s) obtained with the method getResultSet.
 boolean getMoreResults(int current)
          Javadoc taken from Statement interface : Moves to this Statement object's next result, deals with any current ResultSet object(s) according to the instructions specified by the given flag, and returns true if the next result is a ResultSet object.
 int getQueryTimeout()
          Javadoc taken from Statement interface : Retrieves the number of seconds the driver will wait for a Statement object to execute.
 java.sql.ResultSet getResultSet()
          Javadoc taken from Statement interface : Retrieves the current result as a ResultSet object.
 int getResultSetConcurrency()
          Javadoc taken from Statement interface : Retrieves the result set concurrency for ResultSet objects generated by this Statement object.
 int getResultSetHoldability()
          Javadoc taken from Statement interface : Retrieves the result set holdability for ResultSet objects generated by this Statement object.
 int getResultSetType()
          Javadoc taken from Statement interface : Retrieves the result set type for ResultSet objects generated by this Statement object.
 TLptsRowSet getRowSet()
          Gets the RowSet for this statement after execution.
 XLptsDBStatementColumnType getSelectedColumnItemByIndex(int index)
          Gets the selected column by it's INDEX.
 java.util.List<XLptsDBStatementColumnType> getSelectedColumnList()
           This function returns the columns that are currently selected for this statement.
 java.util.List<java.lang.String> getSelectedColumnNameList()
           Gets a list of names for the currently selected columns of this statement.
 java.lang.String getSqlStatementExtension()
          This is an override of the XLptsDBStatementType getSqlStatementExtension.
 java.lang.String getSqlStatementFormatted()
          Gets the formatted SQL String for the current statement after setting statement parameters.
 int getSqlType(int sqlColumnIndex)
          Gets the SQL Type for the selected column index.
 XLptsDBSqlStringFormatType getStandardSqlFormat(XLptsDBSqlDatabaseFormat type)
          Gets the SQL String formats for the standard types, like MS SQL, MySql, Postgres and ODBC.
 XLptsDBStatementTableType getTableItemById(java.lang.String tableId)
           Gets a specific table by it's id.
 XLptsDBStatementTableType getTableItemByName(java.lang.String tableName)
          Gets a table by name.
 java.util.List<XLptsDBStatementTableType> getTableListItem()
           Gets a copy of the actual table list for this statement.
 int getUpdateCount()
          Javadoc taken from Statement interface : Retrieves the current result as an update count; if the result is a ResultSet object or there are no more results, -1 is returned.
 java.util.List<XLptsDBUpInsDelType> getUpInsDelListItem()
          Gets a copy of the list of items to be used for update/insert/delete processing on this statement.
 java.sql.SQLWarning getWarnings()
          Javadoc taken from Statement interface : Retrieves the first warning reported by calls on this Statement object.
 boolean hasDynamicSubStatement()
          Tells us if the current statement has a dynamic sub-statement (ie is a primary statement).
 boolean hasPrimaryStatement()
          Tells us if this statement has a primary statement (ie if it is dynamic).
 void initTablesAndColumns(int tableTypes)
          Loads the specified types of tables, and their columns, into the current statement.
 void interruptExecution()
          Interrupts current statement execution.
 boolean isClosed()
          Javadoc taken from Statement interface : Retrieves whether this Statement object has been closed.
 boolean isInterrupted()
          Tells us if the statement execution was interrupted.
 boolean isPoolable()
          Javadoc taken from Statement interface : Returns a value indicating whether the Statement is poolable or not.
 boolean isWrapperFor(java.lang.Class<?> iface)
          Javadoc taken from Statement interface : Returns true if this either implements the interface argument or is directly or indirectly a wrapper for an object that does.
 void resetAllTablesAndColumns()
          Deselects all tables and columns for the current statement.
 void setCursorName(java.lang.String name)
          Javadoc taken from Statement interface : Sets the SQL cursor name to the given String, which will be used by subsequent Statement object execute methods.
 void setEscapeProcessing(boolean enable)
          Javadoc taken from Statement interface : Sets escape processing on or off.
 void setFetchDirection(int direction)
          Javadoc taken from Statement interface : Gives the driver a hint as to the direction in which rows will be processed in ResultSet objects created using this Statement object.
 void setFetchSize(int rows)
          Javadoc taken from Statement interface : 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 ResultSet objects genrated by this Statement.
 void setMaxFieldSize(int max)
          Javadoc taken from Statement interface : Sets the limit for the maximum number of bytes that can be returned for character and binary column values in a ResultSet object produced by this Statement object.
 void setMaxRows(int max)
          Javadoc taken from Statement interface : Sets the limit for the maximum number of rows that any ResultSet object generated by this Statement object can contain to the given number.
 void setObject(int i, java.lang.Object obj, int sqlType)
          Sets an object for substitution at runtime (replaces the ?
 void setPoolable(boolean poolable)
          Javadoc taken from Statement interface : Requests that a Statement be pooled or not pooled.
 void setPrimaryStatement(java.lang.String primaryStatementId, boolean isSubstituteValueIntoSQLString)
          Sets the primary statement for the current statement.
 void setQueryTimeout(int seconds)
          Javadoc taken from Statement interface : Sets the number of seconds the driver will wait for a Statement object to execute to the given number of seconds.
 void setSelectOnAllColumns(java.lang.String tableName, boolean isSelect)
          Sets all the columns for a specific table to be SELECTED or NOT in the SQL statement.
 void setSqlDatabaseFormat(XLptsDBSqlDatabaseFormat value)
          Sets the quotation format for current statement.
 void setSqlStatementExtension(java.lang.String value)
          This is an override of the XLptsDBStatementType setSqlStatementExtension.
 void setSqlStatementUser(java.lang.String value)
          This is an override of XLptsDBStatementType.setSqlStatementUser(String).
 void setTitle(java.lang.String value)
          Overrides of function from XLptsDBStatementType : Sets the title of the statement.
<T> T
unwrap(java.lang.Class<T> iface)
          Javadoc taken from Statement interface : Returns an object that implements the given interface to allow access to non-standard methods, or standard methods not exposed by the proxy.
 void zaCLI(XLptsDBStatementColumnType sct)
          Obfuscated as it is not required by the application interface.
 void zaTLI(XLptsDBStatementTableType stt)
          Obfuscated as it is not required by the application interface.
 void zaUIDLI(XLptsDBUpInsDelType uidt)
          Obfuscated as it is not required by the application interface.
 void zcUIDLI()
          Obfuscated as it is not required by the application interface.
 int zgCI(XLptsDBStatementColumnType column)
          Obfuscated as it is not required by the application interface.
 java.util.List<com.lapetus_ltd.api.db.control.TLptsStatement.SetObjectClass> zgOL()
          Obfuscated.
 java.lang.String zgSSS()
          Obfuscated as it is not required by the application interface.
 boolean ziSS()
          Obfuscated as it is not required by the application interface.
 boolean zpPR()
          Obfuscated as it is not required by the application interface.
 void zrc(XLptsDBStatementColumnType sct)
          Obfuscated as it is not required by the application interface.
 void zrI()
          Obfuscated as it is not required by the application interface.
 void zrTLI(XLptsDBStatementTableType stt)
          Obfuscated as it is not required by the application interface.
 void zrUIDLI(XLptsDBUpInsDelType uidt)
          Obfuscated as it is not required by the application interface.
 void zsOL()
          Obfuscated.
 void zsR(TLptsRowSet rowSet)
          Obfuscated as it is not required by the application interface.
 void zsS(java.sql.Statement statement)
          Obfuscated as it is not required by the application interface.
 void zsSS(boolean setSub)
          Obfuscated as it is not required by the application interface.
 void zsSSS(java.lang.String sql)
          Obfuscated as it is not required by the application interface.
 
Methods inherited from class com.lapetus_ltd._2009.xml.types.XLptsDBStatementType
getCharset, getConnectionId, getCreateRootItem, getCriteriaType, getId, getSqlDatabaseFormat, getSqlStatementUnformatted, getSqlStatementUser, getSqlStringFormat, getTableTypesView, getTitle, getTypeOfStatement, getVersion, getXResultSetConcurrency, getXResultSetType, isExecutable, isSqlStatementModified, isVisible, setCharset, setConnectionId, setCreateRootItem, setCriteriaType, setExecutable, setId, setSqlStatementModified, setSqlStatementUnformatted, setSqlStringFormat, setTableTypesView, setTypeOfStatement, setVersion, setVisible, setXResultSetConcurrency, setXResultSetType
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TLptsStatement

public TLptsStatement(TLptsConnection connection,
                      XLptsDBStatementType statementType)
This Constructor create a new Statement by setting only the connection and loading all the fields from another Statement.

Thread Safe : Yes

Spawns its own Thread : No

May Return NULL : No

Notes :

Example :


 TLptsConnection connection;
 TLptsStatement statement;

 ...
 //load project from XML files
 XLptsDBStatementType statementType //statement loaded from project

 statement = new TLptsStatement(connection,statementType);

 

Parameters:
connection - is the statement's connection
statementType - is the statement to load values from

TLptsStatement

public TLptsStatement(TLptsConnection connection,
                      XLptsDBTypeOfStatementType typeOfStatement)
Creates a new Statement by setting the connection and the type of the statement.

Thread Safe : Yes

Spawns its own Thread : No

May Return NULL : No

Notes : Types of statement are: SELECT, CREATE, UPDATE, INSERT, DELETE

Example :

 // lets create a simple statement with one table and all columns selected.

 TLptsStatement statement = new TLptsStatement(connection,XLptsDBTypeOfStatementType.SELECT);
 // set the table and columns for selecting
 XLptsDBStatementTableType table =  statement.getTableItemByName(tableName);
 table.setSelected(true);
 statement.setSelectOnAllColumns(tableName, true);
 statement.getCriteriaType().setType(XLptsDBCriteriaType.NONE);
 statement.setTitle(tableName);
 System.out.println("SQL Statement " + statement.getTitle() + ": " + statement.getSqlStatementFormatted());
 
 TLptsFactoryStatement.createNewStatement(connection,statement);
 // then catch with the factory statement listener OR
 TLptsFactoryRowSet.executeSelectStatement(statement);
 // then catch with the factory rowset listener

 ------------ OR A SIMPLE CASE WITH THE NORMAL RESULTSET PROCESSING ----------------

  TLptsStatement statement = new TLptsStatement(lptsConnection, XLptsDBTypeOfStatementType.SELECT);

  XLptsDBStatementTableType table = statement.getTableItemByName(TABLE_NAME);
  if (table == null)
    return ;

  table.setSelected(true);
  statement.setSelectOnAllColumns(table.getTableName(), true);
  statement.setSqlDatabaseFormat(XLptsDBSqlDatabaseFormat.DEFAULT_MYSQL);
  statement.getCriteriaType().setType(XLptsDBCriteriaType.NONE);
  statement.setTitle("NAME");

  try
  {
    PreparedStatement stmt = lptsConnection.prepareStatement(statement.getSqlStatementFormatted());
    ResultSet rs = stmt.executeQuery(statement.getSqlStatementFormatted());
    while (rs.next())
    {
      if (rs.getString(COLUMN_1)!=null)
        if (rs.getString(COLUMN_2)!=null)
          if (rs.getString(COLUMN_3)!=null)
            processData(rs.getString(COLUMN_1),rs.getString(COLUMN_2),rs.getString(COLUMN_3)) ;
    }
  } catch (Exception e)
  {
    // react
  }

 

Parameters:
connection - is the statement's connection
typeOfStatement - is the type of new statement
Method Detail

addBatch

public void addBatch(java.lang.String sql)
              throws java.sql.SQLException
Javadoc taken from Statement interface : Adds the given SQL command to the current list of commmands for this Statement object. The commands in this list can be executed as a batch by calling the method executeBatch.

Specified by:
addBatch in interface java.sql.Statement
Parameters:
sql - typically this is a SQL INSERT or UPDATE statement
Throws:
java.sql.SQLException - if a database access error occurs, this method is called on a closed Statement or the driver does not support batch updates
Since:
1.2
See Also:
executeBatch(), DatabaseMetaData.supportsBatchUpdates()

addPrimaryRelationship

public void addPrimaryRelationship(int localColumnIndex,
                                   int[] foreignColumnIndexes,
                                   java.lang.String operation)
Adds a primary relationship of the current statement with the primary statement.

Thread Safe : Yes

Spawns its own Thread : No

May Return NULL : N/A

Notes :
This function is always accompanied by setPrimaryStatement(java.lang.String, boolean).
THE PRIMARY STATEMENT NEEDS TO BE SET BEFORE WE CALL THIS FUNCTION.
Together these functions specify a link or relationship between two statements.
The statement that calls these functions is the dynamic statement, which means that it is executed with every row
of the primary statement, taking the values specified from the primary statement's current row and substituting
them into the current statement and then execute the resultset.
In the example below we have 3 statements, namely Customers, Accounts and transactions. Customer is the top primary
and feeds data to account. For every account of the current customer, data is fed to the transactions so that we have
a 3 level dynamic statement relationship. There is no limit to the number of levels we can declare and execute.
This brings about one or many rowsets per customer for accounts, and one or many rowsets per account for transactions.
So in the end there is a tree or rowsets built, with the customer statement as the top level.
Each row comes down to the application with identification as to its statement, rowset and own id. The application can
then easily map the rows to a hierarchy structure (as shown in TLptsRowEvent.getRowObjectList()).

Example :

 ...
  // first we create the customer, account and transaction statements. Then we dynamically link them.
  // once they are linked, dbJAPI will process the hole structure and provide each record, one at a time, to the application
 // through the listener, with reference to its position in the structure. The application can then process the records as
 // required, with the correct structure. (like the data view window does TLptsViewDataDialog)

  TLptsStatement customerStatement, transStatement, itemStatement;

  ////////////////////////////////// CUSTOMER  ////////////////////////////////////

  // contains all the tables and columns of the connection. We need to select some or input a SQL string manually
  customerStatement = new TLptsStatement(connection,XLptsDBTypeOfStatementType.SELECT);
  customerStatement.setTitle("CUSTOMERS");
  // the quotations are for ODBC
  customerStatement.setSqlDatabaseFormat(XLptsDBSqlDatabaseFormat.DEFAULT_MYSQL);

  XLptsDBStatementTableType table = customerStatement.getTableItemByName("CUSTOMERS");
  table.setSelected(true); // selecting one table only, with all its columns
  customerStatement.setSelectOnAllColumns(table.getTableName(), true);

  // make sure this is not processed as we are waiting for the dynamic statements below to be created.
  customerStatement.setExecutable(false);
  TLptsFactoryStatement.createNewStatement(connection, customerStatement);

  ////////////////////////////////// ACCOUNT  ////////////////////////////////////

  accountStatement = new TLptsStatement(connection,XLptsDBTypeOfStatementType.SELECT);
  accountStatement.setTitle("TRANSACTIONS");
  accountStatement.setSqlDatabaseFormat(XLptsDBSqlDatabaseFormat.DEFAULT_MYSQL);

  table = accountStatement.getTableItemByName("TRANSACTIONS");
  table.setSelected(true); // selecting one table only, with all its columns
  accountStatement.setSelectOnAllColumns(table.getTableName(), true);  // select all the columns and the select statement SQL string will be created automatically.

  // relate this statement to the customer statement (this means that 'customer' will feed the data to this statement for every record of 'customer' to regenerate this statement every time)
  accountStatement.setPrimaryStatement(customerStatement.getId(),false);  // false means that we do not want static string substitution (uses the setObject of Statement)
  accountStatement.addPrimaryRelationship(2,new int[] {1}, TLptsFactoryStatement.OPERATION_EQUAL); // column 2 in this statement is related to column 1 in customer
                                                                                                   // certain operations allow for many indexes (like IN and BETWEEN)

  // make sure this is not processed as we are waiting for the dynamic statement below to be created.
  accountStatement.setExecutable(false);
  TLptsFactoryStatement.createNewStatement(connection, accountStatement);

  ////////////////////////////////// TRANSACTION  ////////////////////////////////////

  transStatement = new TLptsStatement(connection,XLptsDBTypeOfStatementType.SELECT);
  transStatement.setTitle("TRANSACTIONS");
  transStatement.setSqlDatabaseFormat(XLptsDBSqlDatabaseFormat.DEFAULT_MYSQL);

  table = transStatement.getTableItemByName("TRANSACTIONS");
  table.setSelected(true); // selecting one table only, with all its columns
  transStatement.setSelectOnAllColumns(table.getTableName(), true);  // select all the columns and the select statement SQL string will be created automatically.

  // relate this statement to the account statement (this means that 'account' will feed the data to this statement for every record of 'account' to regenerate this statement every time)
  transStatement.setPrimaryStatement(accountStatement.getId(),false);  // false means that we do not want static string substitution (false uses the setObject of Statement)
  transStatement.addPrimaryRelationship(2,new int[] {1}, TLptsFactoryStatement.OPERATION_EQUAL); // column 2 in this statement is related to column 1 in account
                                                                                                 // certain operations allow for many indexes (like IN and BETWEEN)

  // this statement can be processed now that all the statements are ready and created. This will execute the others dynamically
  transStatement.setExecutable(false);
  TLptsFactoryStatement.createNewStatement(connection, transStatement);
 ...
 

Parameters:
localColumnIndex - The index of the column in the current statement (1 based) to link to the other statement with the operation below.
foreignColumnIndexes - The index (1 based) of the column in the primary statement to link to this statement's column at localColumnIndex.
operation - This is the operation that in put into the where clause for these columns. This is then processed by the SQL processor of the data source so that the resultset can be formed.

cancel

public void cancel()
            throws java.sql.SQLException
Javadoc taken from Statement interface : Cancels this Statement object if both the DBMS and driver support aborting an SQL statement. This method 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 or this method is called on a closed Statement
java.sql.SQLFeatureNotSupportedException - if the JDBC driver does not support this method

clearBatch

public void clearBatch()
                throws java.sql.SQLException
Javadoc taken from Statement interface : Empties this Statement object's current list of SQL commands.

Specified by:
clearBatch in interface java.sql.Statement
Throws:
java.sql.SQLException - if a database access error occurs, this method is called on a closed Statement or the driver does not support batch updates
Since:
1.2
See Also:
addBatch(java.lang.String), DatabaseMetaData.supportsBatchUpdates()

clearWarnings

public void clearWarnings()
                   throws java.sql.SQLException
Javadoc taken from Statement interface : Clears all the warnings reported on this Statement object. After a call to this method, the method getWarnings will return null until a new warning is reported for this Statement object.

Specified by:
clearWarnings in interface java.sql.Statement
Throws:
java.sql.SQLException - if a database access error occurs or this method is called on a closed Statement

close

public void close()
           throws java.sql.SQLException
Javadoc taken from Statement interface : Releases this Statement object's database and JDBC resources immediately instead of waiting for this to happen when it is automatically closed. It is generally good practice to release resources as soon as you are finished with them to avoid tying up database resources.

Calling the method close on a Statement object that is already closed has no effect.

Note:When a Statement object is closed, its current ResultSet object, if one exists, is also closed.

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

closeWE

public boolean closeWE()

Close current statement.

Thread Safe : Yes

Spawns its own Thread : No

May Return NULL : No

Notes :

Example :

 private class RowSetListener implements ILptsFactoryRowSetListener
 {
   public void rowEvent(TLptsRowEvent rowEvent)
   {
     if(rowEvent.getEventType()==TLptsRowEvent.EVENT_TYPE.EXECUTION_INTERRUPTED)
     {
        if(rowEvent.getStatement().isInterrupted())
        {
          if(rowEvent.getStatement().close())
            System.out.println("Process Complete, statement close successfully");
          else
            System.out.println("Process Complete, statement did not close");
        }
     }
     else
     {
       if(rowEvent.getStatement().getId().equals(statementId))
         if(rowEvent.getCurrentRowNo()> desiredNumberOfProcessedRows)
           rowEvent.getStatement().interruptExecution();
     }
   }
   public boolean processNewRowSetRows(TLptsRowSetEvent rowSetEvent)
   {

     return true;
   }
 }
 

Returns:
true if statement closed successfully, else false

equals

public boolean equals(java.lang.Object obj)
Compares the objects by their ID.

Overrides:
equals in class java.lang.Object
Parameters:
obj - An object of type TLptsStatement.
Returns:
True if the ID is equal.

execute

public boolean execute(java.lang.String sql)
                throws java.sql.SQLException
Javadoc taken from Statement interface : Executes the given SQL statement, which may return multiple results. In some (uncommon) situations, a single SQL statement may return multiple result sets and/or update counts. Normally you can ignore this unless you are (1) executing a stored procedure that you know may return multiple results or (2) you are dynamically executing an unknown SQL string.

The execute method executes an SQL statement and indicates the form of the first result. You must then use the methods getResultSet or getUpdateCount to retrieve the result, and getMoreResults to move to any subsequent result(s).

Specified by:
execute in interface java.sql.Statement
Parameters:
sql - any SQL statement
Returns:
true if the first result is a ResultSet object; false if it is an update count or there are no results
Throws:
java.sql.SQLException - if a database access error occurs or this method is called on a closed Statement
See Also:
getResultSet(), getUpdateCount(), getMoreResults()

execute

public boolean execute(java.lang.String sql,
                       int autoGeneratedKeys)
                throws java.sql.SQLException
Javadoc taken from Statement interface : Executes the given SQL statement, which may return multiple results, and signals the driver that any auto-generated keys should be made available for retrieval. The driver will ignore this signal if the SQL statement is not an INSERT statement, or an SQL statement able to return auto-generated keys (the list of such statements is vendor-specific).

In some (uncommon) situations, a single SQL statement may return multiple result sets and/or update counts. Normally you can ignore this unless you are (1) executing a stored procedure that you know may return multiple results or (2) you are dynamically executing an unknown SQL string.

The execute method executes an SQL statement and indicates the form of the first result. You must then use the methods getResultSet or getUpdateCount to retrieve the result, and getMoreResults to move to any subsequent result(s).

Specified by:
execute in interface java.sql.Statement
Parameters:
sql - any SQL statement
autoGeneratedKeys - a constant indicating whether auto-generated keys should be made available for retrieval using the method getGeneratedKeys; one of the following constants: Statement.RETURN_GENERATED_KEYS or Statement.NO_GENERATED_KEYS
Returns:
true if the first result is a ResultSet object; false if it is an update count or there are no results
Throws:
java.sql.SQLException - if a database access error occurs, this method is called on a closed Statement or the second parameter supplied to this method is not Statement.RETURN_GENERATED_KEYS or Statement.NO_GENERATED_KEYS.
java.sql.SQLFeatureNotSupportedException - if the JDBC driver does not support this method with a constant of Statement.RETURN_GENERATED_KEYS
Since:
1.4
See Also:
getResultSet(), getUpdateCount(), getMoreResults(), getGeneratedKeys()

execute

public boolean execute(java.lang.String sql,
                       int[] columnIndexes)
                throws java.sql.SQLException
Javadoc taken from Statement interface : Executes the given SQL statement, which may return multiple results, and signals the driver that the auto-generated keys indicated in the given array should be made available for retrieval. This array contains the indexes of the columns in the target table that contain the auto-generated keys that should be made available. The driver will ignore the array if the SQL statement is not an INSERT statement, or an SQL statement able to return auto-generated keys (the list of such statements is vendor-specific).

Under some (uncommon) situations, a single SQL statement may return multiple result sets and/or update counts. Normally you can ignore this unless you are (1) executing a stored procedure that you know may return multiple results or (2) you are dynamically executing an unknown SQL string.

The execute method executes an SQL statement and indicates the form of the first result. You must then use the methods getResultSet or getUpdateCount to retrieve the result, and getMoreResults to move to any subsequent result(s).

Specified by:
execute in interface java.sql.Statement
Parameters:
sql - any SQL statement
columnIndexes - an array of the indexes of the columns in the inserted row that should be made available for retrieval by a call to the method getGeneratedKeys
Returns:
true if the first result is a ResultSet object; false if it is an update count or there are no results
Throws:
java.sql.SQLException - if a database access error occurs, this method is called on a closed Statement or the elements in the int array passed to this method are not valid column indexes
java.sql.SQLFeatureNotSupportedException - if the JDBC driver does not support this method
Since:
1.4
See Also:
getResultSet(), getUpdateCount(), getMoreResults()

execute

public boolean execute(java.lang.String sql,
                       java.lang.String[] columnNames)
                throws java.sql.SQLException
Javadoc taken from Statement interface : Executes the given SQL statement, which may return multiple results, and signals the driver that the auto-generated keys indicated in the given array should be made available for retrieval. This array contains the names of the columns in the target table that contain the auto-generated keys that should be made available. The driver will ignore the array if the SQL statement is not an INSERT statement, or an SQL statement able to return auto-generated keys (the list of such statements is vendor-specific).

In some (uncommon) situations, a single SQL statement may return multiple result sets and/or update counts. Normally you can ignore this unless you are (1) executing a stored procedure that you know may return multiple results or (2) you are dynamically executing an unknown SQL string.

The execute method executes an SQL statement and indicates the form of the first result. You must then use the methods getResultSet or getUpdateCount to retrieve the result, and getMoreResults to move to any subsequent result(s).

Specified by:
execute in interface java.sql.Statement
Parameters:
sql - any SQL statement
columnNames - an array of the names of the columns in the inserted row that should be made available for retrieval by a call to the method getGeneratedKeys
Returns:
true if the next result is a ResultSet object; false if it is an update count or there are no more results
Throws:
java.sql.SQLException - if a database access error occurs, this method is called on a closed Statement or the elements of the String array passed to this method are not valid column names
java.sql.SQLFeatureNotSupportedException - if the JDBC driver does not support this method
Since:
1.4
See Also:
getResultSet(), getUpdateCount(), getMoreResults(), getGeneratedKeys()

executeBatch

public int[] executeBatch()
                   throws java.sql.SQLException
Javadoc taken from Statement interface : Submits a batch of commands to the database for execution and if all commands execute successfully, returns an array of update counts. The int elements of the array that is returned are ordered to correspond to the commands in the batch, which are ordered according to the order in which they were added to the batch. The elements in the array returned by the method executeBatch may be one of the following:
  1. A number greater than or equal to zero -- indicates that the command was processed successfully and is an update count giving the number of rows in the database that were affected by the command's execution
  2. A value of SUCCESS_NO_INFO -- indicates that the command was processed successfully but that the number of rows affected is unknown

    If one of the commands in a batch update fails to execute properly, this method throws a BatchUpdateException, and a JDBC driver may or may not continue to process the remaining commands in the batch. However, the driver's behavior must be consistent with a particular DBMS, either always continuing to process commands or never continuing to process commands. If the driver continues processing after a failure, the array returned by the method BatchUpdateException.getUpdateCounts will contain as many elements as there are commands in the batch, and at least one of the elements will be the following:

  3. A value of EXECUTE_FAILED -- indicates that the command failed to execute successfully and occurs only if a driver continues to process commands after a command fails

The possible implementations and return values have been modified in the Java 2 SDK, Standard Edition, version 1.3 to accommodate the option of continuing to proccess commands in a batch update after a BatchUpdateException obejct has been thrown.

Specified by:
executeBatch in interface java.sql.Statement
Returns:
an array of update counts containing one element for each command in the batch. The elements of the array are ordered according to the order in which commands were added to the batch.
Throws:
java.sql.SQLException - if a database access error occurs, this method is called on a closed Statement or the driver does not support batch statements. Throws BatchUpdateException (a subclass of SQLException) if one of the commands sent to the database fails to execute properly or attempts to return a result set.
Since:
1.3
See Also:
addBatch(java.lang.String), DatabaseMetaData.supportsBatchUpdates()

executeQuery

public java.sql.ResultSet executeQuery()
Executes the query of the selected statement.

Thread Safe : Yes

Spawns its own Thread : No

May Return NULL : Yes. An error is logged in TLptsLogger, when NULL is returned.

Notes :
This is done automatically by TLptsFactoryRowSet when executing a statement TLptsFactoryRowSet.executeSelectStatement(com.lapetus_ltd.api.db.control.TLptsStatement, int, int, boolean).

Example :

 private void selectDataStatements(TLptsConnection connection, String columnName)
 {
   TLptsStatement statement = new TLptsStatement(connection,XLptsDBTypeOfStatementType.SELECT);
   // set the table and columns for selecting
   statement.setSqlStatementUser("SELECT * FROM [testTable] WHERE [testTable].[Occupation] <> N'Software Developer'");
   // the statement is modified by hand and will not be generated from the selected tables and columns.
   statement.setSqlStatementModified(true);
   statement.setTitle(columnName);
   processData(statement.executeQuery());
 }

 private void processData(ResultSet rs)
 {
    ...
    while (rs.next)
     ...
 }

 

Returns:
the result set from the executed statement

executeQuery

public java.sql.ResultSet executeQuery(java.lang.String sql)
                                throws java.sql.SQLException
Javadoc taken from Statement interface : Executes the given SQL statement, which returns a single ResultSet object.

Specified by:
executeQuery in interface java.sql.Statement
Parameters:
sql - an SQL statement to be sent to the database, typically a static SQL SELECT statement
Returns:
a ResultSet object that contains the data produced by the given query; never null
Throws:
java.sql.SQLException - if a database access error occurs, this method is called on a closed Statement or the given SQL statement produces anything other than a single ResultSet object

executeUpdate

public int executeUpdate()
Executes an Update on a PreparedStatement.

Thread Safe : Yes

Spawns its own Thread : No, but it is executed within a worker thread if called by TLptsFactoryRowSet

May Return NULL : N/A

Notes :
This is executed by TLptsFactoryRowSet.executeDynamicDelete(com.lapetus_ltd.api.db.control.TLptsStatement),
TLptsFactoryRowSet.executeDynamicInsert(com.lapetus_ltd.api.db.control.TLptsStatement),
TLptsFactoryRowSet.executeDynamicUpdate(com.lapetus_ltd.api.db.control.TLptsStatement).

This should also be called for CREATE statements after their creation TLptsFactoryStatement.createNewStatement(com.lapetus_ltd.api.db.control.TLptsConnection, com.lapetus_ltd._2009.xml.types.XLptsDBStatementType), as in the example.
Example :

  private class CreateStatementListener implements ILptsFactoryStatementListener
  {
    ...
    public void newStatementCreated(TLptsConnection connection, TLptsStatement statement)
    {
      if(statement.getTypeOfStatement()==XLptsDBTypeOfStatementType.CREATE)
      {
        if (!TLptsFactoryStatement.initiatePrepareStatement(statement))
          return;
        statement.executeUpdate();
      }
    }
    ...
  }
 

Returns:
the row count for the number of updated rows. 0 is returned on error or is nothing is updated. TLptsLogger will have a log in case of error.

executeUpdate

public int executeUpdate(java.lang.String sql)
                  throws java.sql.SQLException
Javadoc taken from Statement interface : Executes the given SQL statement, which may be an INSERT, UPDATE, or DELETE statement or an SQL statement that returns nothing, such as an SQL DDL statement.

Specified by:
executeUpdate in interface java.sql.Statement
Parameters:
sql - an SQL Data Manipulation Language (DML) statement, such as INSERT, UPDATE or DELETE; or an SQL statement that returns nothing, such as a DDL statement.
Returns:
either (1) the row count for SQL Data Manipulation Language (DML) statements or (2) 0 for SQL statements that return nothing
Throws:
java.sql.SQLException - if a database access error occurs, this method is called on a closed Statement or the given SQL statement produces a ResultSet object

executeUpdate

public int executeUpdate(java.lang.String sql,
                         int autoGeneratedKeys)
                  throws java.sql.SQLException
Javadoc taken from Statement interface : Executes the given SQL statement and signals the driver with the given flag about whether the auto-generated keys produced by this Statement object should be made available for retrieval. The driver will ignore the flag if the SQL statement is not an INSERT statement, or an SQL statement able to return auto-generated keys (the list of such statements is vendor-specific).

Specified by:
executeUpdate in interface java.sql.Statement
Parameters:
sql - an SQL Data Manipulation Language (DML) statement, such as INSERT, UPDATE or DELETE; or an SQL statement that returns nothing, such as a DDL statement.
autoGeneratedKeys - a flag indicating whether auto-generated keys should be made available for retrieval; one of the following constants: Statement.RETURN_GENERATED_KEYS Statement.NO_GENERATED_KEYS
Returns:
either (1) the row count for SQL Data Manipulation Language (DML) statements or (2) 0 for SQL statements that return nothing
Throws:
java.sql.SQLException - if a database access error occurs, this method is called on a closed Statement, the given SQL statement returns a ResultSet object, or the given constant is not one of those allowed
java.sql.SQLFeatureNotSupportedException - if the JDBC driver does not support this method with a constant of Statement.RETURN_GENERATED_KEYS
Since:
1.4

executeUpdate

public int executeUpdate(java.lang.String sql,
                         int[] columnIndexes)
                  throws java.sql.SQLException
Javadoc taken from Statement interface : Executes the given SQL statement and signals the driver that the auto-generated keys indicated in the given array should be made available for retrieval. This array contains the indexes of the columns in the target table that contain the auto-generated keys that should be made available. The driver will ignore the array if the SQL statement is not an INSERT statement, or an SQL statement able to return auto-generated keys (the list of such statements is vendor-specific).

Specified by:
executeUpdate in interface java.sql.Statement
Parameters:
sql - an SQL Data Manipulation Language (DML) statement, such as INSERT, UPDATE or DELETE; or an SQL statement that returns nothing, such as a DDL statement.
columnIndexes - an array of column indexes indicating the columns that should be returned from the inserted row
Returns:
either (1) the row count for SQL Data Manipulation Language (DML) statements or (2) 0 for SQL statements that return nothing
Throws:
java.sql.SQLException - if a database access error occurs, this method is called on a closed Statement, the SQL statement returns a ResultSet object, or the second argument supplied to this method is not an int array whose elements are valid column indexes
java.sql.SQLFeatureNotSupportedException - if the JDBC driver does not support this method
Since:
1.4

executeUpdate

public int executeUpdate(java.lang.String sql,
                         java.lang.String[] columnNames)
                  throws java.sql.SQLException
Javadoc taken from Statement interface : Executes the given SQL statement and signals the driver that the auto-generated keys indicated in the given array should be made available for retrieval. This array contains the names of the columns in the target table that contain the auto-generated keys that should be made available. The driver will ignore the array if the SQL statement is not an INSERT statement, or an SQL statement able to return auto-generated keys (the list of such statements is vendor-specific).

Specified by:
executeUpdate in interface java.sql.Statement
Parameters:
sql - an SQL Data Manipulation Language (DML) statement, such as INSERT, UPDATE or DELETE; or an SQL statement that returns nothing, such as a DDL statement.
columnNames - an array of the names of the columns that should be returned from the inserted row
Returns:
either the row count for INSERT, UPDATE, or DELETE statements, or 0 for SQL statements that return nothing
Throws:
java.sql.SQLException - if a database access error occurs, this method is called on a closed Statement, the SQL statement returns a ResultSet object, or the second argument supplied to this method is not a String array whose elements are valid column names
java.sql.SQLFeatureNotSupportedException - if the JDBC driver does not support this method
Since:
1.4

findTopPrimaryStatement

public TLptsStatement findTopPrimaryStatement()
Gets the top primary statement (level 1).

Thread Safe : Yes

Spawns its own Thread : No

May Return NULL : No, but it could return it's own ID if it is the top statement or the only statement.

Notes :

Example :


 private class RowSetListener implements ILptsFactoryRowSetListener
 {
   private Map treeMap = Collections.synchronizedMap(new LinkedHashMap());

   public boolean processNewRowSetRows(TLptsRowSetEvent rowSetEvent)
   {
     System.out.println("The ID of the top primary to this statement is : " + rowEvent.getStatement().findTopPrimaryStatement().getId());
     return false; // tell dbJAPI not to process the rowset
   }

   public void rowEvent(final TLptsRowEvent rowEvent)
   {
     // nothing to do here
   }
 }
 

Returns:
the top primary statement

geSelectedColumnSqlTypeList

public java.util.List<java.lang.Integer> geSelectedColumnSqlTypeList()
Gets a list of SQL types for the currently selected columns of this statement.

Thread Safe : Yes

Spawns its own Thread : No

May Return NULL : Never, an empty list in the worst case.

Notes :

Example :


 // print out the column names with their SQL types below
 System.out.println("Column Names : ");

 for (List name : getSelectedColumnNameList())
   System.out.print("\t" + name);

 System.out.println("SQL Types    : ");

 for (List sqlType : geSelectedColumnSqlTypeList())
   System.out.print("\t" + sqlType);

 

Returns:
Returns a new copy of the list of SQL types.

getColumnItemById

public XLptsDBStatementColumnType getColumnItemById(java.lang.String id)
Gets a column by it's ID.

Thread Safe : Yes

Spawns its own Thread : No

May Return NULL : Yes

Notes :

Example :


 TLptsStatement statement;
 String columnId;
 ...
 XLptsDBStatementColumnType column = statement.getColumnItemById(columnId);
 ...

 

Parameters:
id - is the unique id of the desired column
Returns:
the column with the unique ID or NULL.

getColumnItemByName

public XLptsDBStatementColumnType getColumnItemByName(java.lang.String tableName,
                                                      java.lang.String columnName)
Gets a column by it's name and table name.

Thread Safe : Yes

Spawns its own Thread : No

May Return NULL : Yes

Notes :

Example :

 // Here are the selected columns
 // -------------------------------------------------------
 // |table1.column1 | table1.column2 | table4.column3 | ...
 // -------------------------------------------------------

 TLptsStatement statement = new TLptsStatement(connection,XLptsDBTypeOfStatementType.SELECT);
 statement.getColumnItemByName("table1","column1").setSelected(true);
 statement.getColumnItemByName("table1","column2").setSelected(true);
 statement.getColumnItemByName("table1","column3").setSelected(true);
 ...
 System.out.println(deleteStatement.getSelectedColumnItemByIndex(1).getTableName() + "." + deleteStatement.getSelectedColumnItemByIndex(1).getColumnName());
 System.out.println(deleteStatement.getSelectedColumnItemByIndex(2).getTableName() + "." + deleteStatement.getSelectedColumnItemByIndex(2).getColumnName());
 System.out.println(deleteStatement.getSelectedColumnItemByIndex(3).getTableName() + "." + deleteStatement.getSelectedColumnItemByIndex(3).getColumnName());

 Result: table1.column1
         table1.column2
         table4.column3
 

Parameters:
tableName - is the name of the table for our column
columnName - is the name of the column
Returns:
the column by table name and column name

getColumnItemsForTable

public java.util.List<XLptsDBStatementColumnType> getColumnItemsForTable(java.lang.String tableName)

Gets a list with all the columns for a table.

Thread Safe : Yes

Spawns its own Thread : No

May Return NULL : Never, an empty list in the worst case.

Notes :

Example :


 private void selectDataStatements(TLptsConnection connection, String tableName, String columnName)
 {
   TLptsStatement statement = new TLptsStatement(connection,XLptsDBTypeOfStatementType.SELECT);
   // set the table and columns for selecting
   XLptsDBStatementTableType table =  statement.getTableItemByName(tableName);
   table.setSelected(true);
   // just one column is selected to be output to the rowset.
   for(XLptsDBStatementColumnType column : statement.getColumnItemsForTable(table.getTableName()))
     if(column.getColumnName().equalsIgnoreCase(columnName))
       column.setSelected(true);
   statement.getCriteriaType().setType(XLptsDBCriteriaType.NONE);
   statement.setTitle(columnName);
   System.out.println("SQL Statement " + statement.getTitle() + ": " + statement.getSqlStatementFormatted());
   TLptsFactoryStatement.createNewStatement(connection,statement);
 }

 

Parameters:
tableName - The table to get the colums for.
Returns:
a synchronised copy of the actual list with all columns for a table

getColumnListItem

public java.util.List<XLptsDBStatementColumnType> getColumnListItem()
Gets a copy of the actual list of all columns from current datasource.

Thread Safe : Yes

Spawns its own Thread : No

May Return NULL : Never, an empty list in the worst case.

Notes : This is a list of all table, not just the selected on for the current statement.

Example :


 TLptsStatement statement = new TLptsStatement(connection,XLptsDBTypeOfStatementType.SELECT);
 ...
 System.out.println("This is a list of all column in the data source :");
 for(XLptsDBStatementColumnType column : statement.getColumnListItem())
   System.out.println("Name=" + column.getColumnName + ", Selected="+(column.isSelected()?"Yes":"No") + ", SQL type="+column.getSqlType());

 

Overrides:
getColumnListItem in class XLptsDBStatementType
Returns:
list with the columns from current Database

getConnection

public java.sql.Connection getConnection()
                                  throws java.sql.SQLException
Javadoc taken from Statement interface : Retrieves the Connection object (TLptsConnection) that produced this Statement object.

This connection is actually of type TLptsConnection.

Specified by:
getConnection in interface java.sql.Statement
Returns:
the TLptsConnection that produced this statement
Throws:
java.sql.SQLException
Since:
1.2

getConnectionWE

public java.sql.Connection getConnectionWE()

Retrieves the Connection object (TLptsConnection) that produced this Statement object.

Thread Safe : Yes

Spawns its own Thread : No

May Return NULL : N/A

Notes : This connection is actually of type TLptsConnection.

Example :


   private class RowSetListener implements ILptsFactoryRowSetListener
   {
     public void rowEvent(TLptsRowEvent rowEvent)
     {
     }
     public boolean processNewRowSetRows(TLptsRowSetEvent rowSetEvent)
     {
       if(rowSetEvent.getEventType()==TLptsRowSetEvent.EVENT_TYPE.INSERT_COMPLETE)
       {
         System.out.println("Statement "+ rowSetEvent.getStatement().getTitle()+" " + ((TLptsConnection) rowSetEvent.getStatement().getConnectionWE()).getTitle()+ " insert execution complete...");
         System.out.println(rowSetEvent.getRows()+" rows inserted, " + rowSetEvent.getObjects() + " objects inserted");
         if(rowSetEvent.getRowSetsNotFinished().isEmpty())
           System.out.println("All row sets has finished");
         else
           for(String rowSet : rowSetEvent.getRowSetsNotFinished())
             System.out.println(rowSet + " did not finished");
       }

       if(rowSetEvent.getEventType()==TLptsRowSetEvent.EVENT_TYPE.ERROR_OCCURRED)
         System.out.println("The insert was not successful. We need to check the output from the logger for more information.");

       // we tell the rowset factory not to process the rows and send them to us via the rowEvent.
       return false;
     }
   }

 

Returns:
the TLptsConnection that produced this statement
Since:
1.2

getFetchDirection

public int getFetchDirection()
                      throws java.sql.SQLException
Javadoc taken from Statement interface : Retrieves the direction for fetching rows from database tables that is the default for result sets generated from this Statement object. If this Statement object has not set a fetch direction by calling the method setFetchDirection, the return value is implementation-specific.

Specified by:
getFetchDirection in interface java.sql.Statement
Returns:
the default fetch direction for result sets generated from this Statement object
Throws:
java.sql.SQLException - if a database access error occurs or this method is called on a closed Statement
Since:
1.2
See Also:
setFetchDirection(int)

getFetchSize

public int getFetchSize()
                 throws java.sql.SQLException
Javadoc taken from Statement interface : Retrieves the number of result set rows that is the default fetch size for ResultSet objects generated from this Statement object. If this Statement object has not set a fetch size by calling the method setFetchSize, the return value is implementation-specific.

Specified by:
getFetchSize in interface java.sql.Statement
Returns:
the default fetch size for result sets generated from this Statement object
Throws:
java.sql.SQLException - if a database access error occurs or this method is called on a closed Statement
Since:
1.2
See Also:
setFetchSize(int)

getGeneratedKeys

public java.sql.ResultSet getGeneratedKeys()
                                    throws java.sql.SQLException
Javadoc taken from Statement interface : Retrieves any auto-generated keys created as a result of executing this Statement object. If this Statement object did not generate any keys, an empty ResultSet object is returned.

Note:If the columns which represent the auto-generated keys were not specified, the JDBC driver implementation will determine the columns which best represent the auto-generated keys.

Specified by:
getGeneratedKeys in interface java.sql.Statement
Returns:
a ResultSet object containing the auto-generated key(s) generated by the execution of this Statement object
Throws:
java.sql.SQLException - if a database access error occurs or this method is called on a closed Statement
java.sql.SQLFeatureNotSupportedException - if the JDBC driver does not support this method
Since:
1.4

getMaxFieldSize

public int getMaxFieldSize()
                    throws java.sql.SQLException
Javadoc taken from Statement interface : Retrieves the maximum number of bytes that can be returned for character and binary column values in a ResultSet object produced by this Statement object. This limit applies only to BINARY, VARBINARY, LONGVARBINARY, CHAR, VARCHAR, NCHAR, NVARCHAR, LONGNVARCHAR 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 column size limit for columns storing character and binary values; zero means there is no limit
Throws:
java.sql.SQLException - if a database access error occurs or this method is called on a closed Statement
See Also:
setMaxFieldSize(int)

getMaxRows

public int getMaxRows()
               throws java.sql.SQLException
Javadoc taken from Statement interface : Retrieves the maximum number of rows that a ResultSet object produced by this Statement object can contain. If this limit is exceeded, the excess rows are silently dropped.

Specified by:
getMaxRows in interface java.sql.Statement
Returns:
the current maximum number of rows for a ResultSet object produced by this Statement object; zero means there is no limit
Throws:
java.sql.SQLException - if a database access error occurs or this method is called on a closed Statement
See Also:
setMaxRows(int)

getMoreResults

public boolean getMoreResults()
                       throws java.sql.SQLException
Javadoc taken from Statement interface : Moves to this Statement object's next result, returns true if it is a ResultSet object, and implicitly closes any current ResultSet object(s) obtained with the method getResultSet.

There are no more results when the following is true:

 // stmt is a Statement object
 ((stmt.getMoreResults() == false) && (stmt.getUpdateCount() == -1))
 

Specified by:
getMoreResults in interface java.sql.Statement
Returns:
true if the next result is a ResultSet object; false if it is an update count or there are no more results
Throws:
java.sql.SQLException - if a database access error occurs or this method is called on a closed Statement
See Also:
execute(java.lang.String)

getMoreResults

public boolean getMoreResults(int current)
                       throws java.sql.SQLException
Javadoc taken from Statement interface : Moves to this Statement object's next result, deals with any current ResultSet object(s) according to the instructions specified by the given flag, and returns true if the next result is a ResultSet object.

There are no more results when the following is true:

 // stmt is a Statement object
 ((stmt.getMoreResults(current) == false) && (stmt.getUpdateCount() == -1))
 

Specified by:
getMoreResults in interface java.sql.Statement
Parameters:
current - one of the following Statement constants indicating what should happen to current ResultSet objects obtained using the method getResultSet: Statement.CLOSE_CURRENT_RESULT, Statement.KEEP_CURRENT_RESULT, or Statement.CLOSE_ALL_RESULTS
Returns:
true if the next result is a ResultSet object; false if it is an update count or there are no more results
Throws:
java.sql.SQLException - if a database access error occurs, this method is called on a closed Statement or the argument supplied is not one of the following: Statement.CLOSE_CURRENT_RESULT, Statement.KEEP_CURRENT_RESULT or Statement.CLOSE_ALL_RESULTS
java.sql.SQLFeatureNotSupportedException - if DatabaseMetaData.supportsMultipleOpenResults returns false and either Statement.KEEP_CURRENT_RESULT or Statement.CLOSE_ALL_RESULTS are supplied as the argument.
Since:
1.4
See Also:
execute(java.lang.String)

getQueryTimeout

public int getQueryTimeout()
                    throws java.sql.SQLException
Javadoc taken from Statement interface : Retrieves the number of seconds the driver will wait for a Statement object to execute. If the limit is exceeded, a SQLException is thrown.

Specified by:
getQueryTimeout in interface java.sql.Statement
Returns:
the current query timeout limit in seconds; zero means there is no limit
Throws:
java.sql.SQLException - if a database access error occurs or this method is called on a closed Statement
See Also:
setQueryTimeout(int)

getResultSet

public java.sql.ResultSet getResultSet()
                                throws java.sql.SQLException
Javadoc taken from Statement interface : Retrieves the current result as a ResultSet object. This method should be called only once per result.

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

getResultSetConcurrency

public int getResultSetConcurrency()
                            throws java.sql.SQLException
Javadoc taken from Statement interface : Retrieves the result set concurrency for ResultSet objects generated by this Statement object.

Specified by:
getResultSetConcurrency in interface java.sql.Statement
Returns:
either ResultSet.CONCUR_READ_ONLY or ResultSet.CONCUR_UPDATABLE
Throws:
java.sql.SQLException - if a database access error occurs or this method is called on a closed Statement
Since:
1.2

getResultSetHoldability

public int getResultSetHoldability()
                            throws java.sql.SQLException
Javadoc taken from Statement interface : Retrieves the result set holdability for ResultSet objects generated by this Statement object.

Specified by:
getResultSetHoldability in interface java.sql.Statement
Returns:
either ResultSet.HOLD_CURSORS_OVER_COMMIT or ResultSet.CLOSE_CURSORS_AT_COMMIT
Throws:
java.sql.SQLException - if a database access error occurs or this method is called on a closed Statement
Since:
1.4

getResultSetType

public int getResultSetType()
                     throws java.sql.SQLException
Javadoc taken from Statement interface : Retrieves the result set type for ResultSet objects generated by this Statement object.

Specified by:
getResultSetType in interface java.sql.Statement
Returns:
one of ResultSet.TYPE_FORWARD_ONLY, ResultSet.TYPE_SCROLL_INSENSITIVE, or ResultSet.TYPE_SCROLL_SENSITIVE
Throws:
java.sql.SQLException - if a database access error occurs or this method is called on a closed Statement
Since:
1.2

getRowSet

public TLptsRowSet getRowSet()
Gets the RowSet for this statement after execution.

Thread Safe : Yes

Spawns its own Thread : No

May Return NULL : Yes

Notes :
With the current structure of dbJAPI this function has no real use.
The reason being that the system takes care of the rowset processing internally, so applications can just listen to the results on ILptsFactoryRowSetListener.

Example :

 ...
 TLptsStatement statement = new TLptsStatement(connection,XLptsDBTypeOfStatementType.SELECT);
 statement.zsR(new TLptsRowSet(statement,statement.executeQuery()));
 ...
 //Later in the code we want to process the execute statement
 processData(statement.getRowSet());
 ...

 

Returns:
the rowSet from the executed statement

getSelectedColumnItemByIndex

public XLptsDBStatementColumnType getSelectedColumnItemByIndex(int index)
Gets the selected column by it's INDEX.

Thread Safe : Yes

Spawns its own Thread : No

May Return NULL : Yes

Notes :

Example :

 // Here are the selected columns
 // -------------------------------------------------------
 // |table1.column1 | table1.column2 | table4.column3 | ...
 // -------------------------------------------------------

 TLptsStatement statement = new TLptsStatement(connection,XLptsDBTypeOfStatementType.SELECT);
 statement.getColumnItemByName("table1","column1").setSelected(true);
 statement.getColumnItemByName("table1","column2").setSelected(true);
 statement.getColumnItemByName("table1","column3").setSelected(true);
 ...
 System.out.println(deleteStatement.getSelectedColumnItemByIndex(1).getTableName() + "." + deleteStatement.getSelectedColumnItemByIndex(1).getColumnName());
 System.out.println(deleteStatement.getSelectedColumnItemByIndex(2).getTableName() + "." + deleteStatement.getSelectedColumnItemByIndex(2).getColumnName());
 System.out.println(deleteStatement.getSelectedColumnItemByIndex(3).getTableName() + "." + deleteStatement.getSelectedColumnItemByIndex(3).getColumnName());

 Result: table1.column1
         table1.column2
         table4.column3
 

Parameters:
index - of the selected column (1 based)
Returns:
The selected column at the index specified or NULL if not found.

getSelectedColumnList

public java.util.List<XLptsDBStatementColumnType> getSelectedColumnList()

This function returns the columns that are currently selected for this statement.

Thread Safe : Yes

Spawns its own Thread : No

May Return NULL : Never, an empty list in the worst case.

Notes : This is a subset of all columns in the datasource and depicts the statement columns to be processed.

Example :


 TLptsStatement statement = new TLptsStatement(connection,XLptsDBTypeOfStatementType.SELECT);
 ...
 System.out.println("This is a list of all Selected column in the data source :");
 for(XLptsDBStatementColumnType column : statement.getColumnListItem())
   System.out.println("Name=" + column.getColumnName + ", SQL type="+column.getSqlType());

 

Returns:
returns a newly created list (copy of the actual list) of the selected columns.

getSelectedColumnNameList

public java.util.List<java.lang.String> getSelectedColumnNameList()

Gets a list of names for the currently selected columns of this statement.

Thread Safe : Yes

Spawns its own Thread : No

May Return NULL : Never, an empty list in the worst case.

Notes : This may return columns from multiple tables, as per the selected tables and columns.

Example :


 // print out the column names with their SQL types below
 System.out.println("Column Names : ");

 for (List name : getSelectedColumnNameList())
   System.out.print("\t" + name);

 System.out.println("SQL Types    : ");

 for (List sqlType : geSelectedColumnSqlTypeList())
   System.out.print("\t" + sqlType);

 

Returns:
Returns the selected column names from all the tables for this data source.

getSqlStatementExtension

public java.lang.String getSqlStatementExtension()
This is an override of the XLptsDBStatementType getSqlStatementExtension.
This is purely for documentation purposes.
This function is used to get the extension of an automatically build string.
It is not used when the SQL string has been manually updated setSqlStatementUser(java.lang.String) & XLptsDBStatementType.setSqlStatementModified(boolean).

Overrides:
getSqlStatementExtension in class XLptsDBStatementType
Returns:
The string which is to be put on the end of the automatically generated string. Normally ORDER BY or SORT.

getSqlStatementFormatted

public java.lang.String getSqlStatementFormatted()
Gets the formatted SQL String for the current statement after setting statement parameters.

Thread Safe : Yes

Spawns its own Thread : No

May Return NULL : No, worst case is an empty string.

Notes :
This function checks the value of XLptsDBStatementType.isSqlStatementModified(), which indicates if a user SQL is to be used
for SQL processing or if the selected tables and columns are to be used to automatically generate the string.
If isSqlStatementModified is true, then the user string is returned without modification.
Otherwise the selected tables and columns, along with the criteria parameters XLptsDBStatementType.getCriteriaType(),
setPrimaryStatement(java.lang.String, boolean) and addPrimaryRelationship(int, int[], java.lang.String).

Example :

 {
  ...
  selectDataStatements(mySqlConnection, "customers", "idcustomers");
 }
 ...
 private void selectDataStatements(TLptsConnection connection, String tableName, String columnName)
 {
   TLptsStatement statement = new TLptsStatement(connection,XLptsDBTypeOfStatementType.SELECT);
   statement.
   XLptsDBStatementTableType table =  statement.getTableItemByName(tableName);
   table.setSelected(true);
   //statement.setSelectOnAllColumns(table.getTable(),true);
   statement.getColumnItemByName(tableName,columnName).setSelected(true);
   statement.getCriteriaType().setType(XLptsDBCriteriaType.NONE);
   statement.setTitle(columnName);

   TLptsFactoryStatement.createNewStatement(connection,statement);
 }

 Result: "SQL Statement idcustomers: SELECT `customers`.`idcustomers` FROM `customers`"
 

Returns:
the formatter SQL String for current statement

getSqlType

public int getSqlType(int sqlColumnIndex)
Gets the SQL Type for the selected column index.

Thread Safe : Yes

Spawns its own Thread : No

May Return NULL : N/A

Notes :

Example :

 ...
 int sqlType = statement.getSqlType(1);  // first sql type of the selected columns
 ...
 

Parameters:
sqlColumnIndex - the selected column index (1 based)
Returns:
the sql type for the selected column or Types.OTHER if not found.

getStandardSqlFormat

public XLptsDBSqlStringFormatType getStandardSqlFormat(XLptsDBSqlDatabaseFormat type)
Gets the SQL String formats for the standard types, like MS SQL, MySql, Postgres and ODBC.

Thread Safe : Yes

Spawns its own Thread : No

May Return NULL : N/A

Notes :

Example :

 statement.setSqlStringFormat(getStandardSqlFormat(XLptsDBSqlDatabaseFormat.DEFAULT_MYSQL));
 

Returns:
Returns the type required by setSqlStringFormat for processing the SQL statement formatting.

getTableItemById

public XLptsDBStatementTableType getTableItemById(java.lang.String tableId)

Gets a specific table by it's id.

Thread Safe : Yes

Spawns its own Thread : No

May Return NULL : N/A

Notes :

Example :

 ...
 // this is a bit foolish, but it helps with the understanding
 XLptsDBStatementTableType tableType = getTableItemByName(tableName);
 // now get the same table, but with the id
 XLptsDBStatementTableType sameTableType = getTableItemById(tableType.getId());
 

Parameters:
tableId - the table id
Returns:
table by id

getTableItemByName

public XLptsDBStatementTableType getTableItemByName(java.lang.String tableName)
Gets a table by name.

Thread Safe : Yes

Spawns its own Thread : No

May Return NULL : N/A

Notes :

Example :


  ...
  customerStatement = new TLptsStatement(connection,XLptsDBTypeOfStatementType.SELECT);
  customerStatement.setTitle("CUSTOMERS");

  // the quotations are for MySQL
  customerStatement.setSqlDatabaseFormat(XLptsDBSqlDatabaseFormat.DEFAULT_MYSQL);

  XLptsDBStatementTableType table = customerStatement.getTableItemByName("CUSTOMERS");
  table.setSelected(true); // selecting one table only, with all its columns
  customerStatement.setSelectOnAllColumns(table.getTableName(), true);

 // dbJAPI automatically formats the SQL statement string so that it is ready for creation and execution.
  TLptsFactoryStatement.createNewStatement(connection, customerStatement);
 ...
 

Parameters:
tableName - The name of the table.
Returns:
Table Statement structure.

getTableListItem

public java.util.List<XLptsDBStatementTableType> getTableListItem()

Gets a copy of the actual table list for this statement.

Thread Safe : Yes

Spawns its own Thread : No

May Return NULL : Never, an empty list in the worst case.

Notes : This list contains all tables of all types.

Example :

 ...
 List selectedTables =  new LinkedList();
 for(XLptsDBStatementTableType table : statement.getTableListItem())
    if(table.isSelected())
      selectedTables.add(table);
 ...
 

Overrides:
getTableListItem in class XLptsDBStatementType
Returns:
Returns all the tables from the connected data source.

getUpdateCount

public int getUpdateCount()
                   throws java.sql.SQLException
Javadoc taken from Statement interface : Retrieves the current result as an update count; if the result is a ResultSet object or there are no more results, -1 is returned. This method should be called only once per result.

Specified by:
getUpdateCount in interface java.sql.Statement
Returns:
the current result as an update count; -1 if the current result is a ResultSet object or there are no more results
Throws:
java.sql.SQLException - if a database access error occurs or this method is called on a closed Statement
See Also:
execute(java.lang.String)

getUpInsDelListItem

public java.util.List<XLptsDBUpInsDelType> getUpInsDelListItem()
Gets a copy of the list of items to be used for update/insert/delete processing on this statement.

Thread Safe : Yes

Spawns its own Thread : No

May Return NULL : Never, an empty list in the worst case.

Notes :

Example :


 for(XLptsDBUpInsDelType uidt : statement.getUpInsDelListItem())
   if(uidt.getSourceType().equals(XLptsDBUpInsDelSourceType.LPTS_STATEMENT))
     for(TLptsStatement stmt : TLptsFactoryStatement.getStatementList())
       if(uidt.getSourceString().equals(stmt.getTitle()))
         System.out.println("Found the statement to be used as a source to this statement.");

 

Overrides:
getUpInsDelListItem in class XLptsDBStatementType
Returns:
list with items that are going to used for update/create/delete

getWarnings

public java.sql.SQLWarning getWarnings()
                                throws java.sql.SQLException
Javadoc taken from Statement interface : Retrieves the first warning reported by calls on this Statement object. Subsequent Statement object warnings will be chained to this SQLWarning object.

The warning chain is automatically cleared each time a statement is (re)executed. This method may not be called on a closed Statement object; doing so will cause an SQLException to be thrown.

Note: If you are processing a ResultSet object, any warnings associated with reads on that ResultSet object will be chained on it rather than on the Statement object that produced it.

Specified by:
getWarnings in interface java.sql.Statement
Returns:
the first SQLWarning object or null if there are no warnings
Throws:
java.sql.SQLException - if a database access error occurs or this method is called on a closed Statement

hasDynamicSubStatement

public boolean hasDynamicSubStatement()
Tells us if the current statement has a dynamic sub-statement (ie is a primary statement).

Thread Safe : Yes

Spawns its own Thread : No

May Return NULL : No

Notes :
A statement can be both dynamic and primary if it is in the middle of a multi-level relationship.

Example :


 public class ProcessData implements ILptsFactoryRowSetListener
 {
   public boolean processNewRowSetRows(TLptsRowSetEvent rowSetEvent)
   {
     if (rowSetEvent.getEventType() == TLptsRowSetEvent.EVENT_TYPE.NEW_SELECT_RESULTSET)
     {
       System.out.println("New rowset is available.");
       if (!rowSetEvent.getStatement().hasPrimaryStatement() && !rowSetEvent.getStatement().hasDynamicSubStatement())
       {
         // this is not a primary set and it does not have a primary (is not dynamic)
         while (rowSetEvent.getRowSet().nextWE())
         {
           // process the row in here
         }
         return false; // TLptsFactoryRowSet should not process this rowset.
       }
     }
     if (rowSetEvent.getPrimaryStatementId() != null)
       System.out.println("The primary statement for this rowset is " + rowSetEvent.getPrimaryStatementId());
     return true; // This is part of a dynamic primary relationship. Let TLptsFactoryRowSet process the rows and send the the rowEvents below.
   }

   public void rowEvent(TLptsRowEvent rowEvent)
   {
     // Here were have the row events. See TLptsRowEvent for more details.
   }
 }
 

Returns:
true if current statement has a dynamic sub statement

hasPrimaryStatement

public boolean hasPrimaryStatement()
Tells us if this statement has a primary statement (ie if it is dynamic).

Thread Safe : Yes

Spawns its own Thread : No

May Return NULL : N/A

Notes :
A statement can be both dynamic and primary if it is in the middle of a multi-level relationship.

Example :


 public class ProcessData implements ILptsFactoryRowSetListener
 {
   public boolean processNewRowSetRows(TLptsRowSetEvent rowSetEvent)
   {
     if (rowSetEvent.getEventType() == TLptsRowSetEvent.EVENT_TYPE.NEW_SELECT_RESULTSET)
     {
       System.out.println("New rowset is available.");
       if (!rowSetEvent.getStatement().hasPrimaryStatement() && !rowSetEvent.getStatement().hasDynamicSubStatement())
       {
         // this is not a primary set and it does not have a primary (is not dynamic)
         while (rowSetEvent.getRowSet().nextWE())
         {
           // process the row in here
         }
         return false; // TLptsFactoryRowSet should not process this rowset.
       }
     }
     if (rowSetEvent.getPrimaryStatementId() != null)
       System.out.println("The primary statement for this rowset is " + rowSetEvent.getPrimaryStatementId());
     return true; // This is part of a dynamic primary relationship. Let TLptsFactoryRowSet process the rows and send the the rowEvents below.
   }

   public void rowEvent(TLptsRowEvent rowEvent)
   {
     // Here were have the row events. See TLptsRowEvent for more details.
   }
 }
 

Returns:
true if the statement has a primary statement, false otherwise.

initTablesAndColumns

public void initTablesAndColumns(int tableTypes)
Loads the specified types of tables, and their columns, into the current statement.

Thread Safe : Yes

Spawns its own Thread : No

May Return NULL : N/A

Notes : Use this to change the types of tables loaded into the statement. Different types are loaded depending on the driver type. Use 'if ((getTableTypesView() & TLptsFactoryStatement.TABLE_TYPE_USER)!=0)' to see if a type is loaded. WARNING: On some databases there may be thousands of tables, and tens of thousands of columns. This may take a while in some cases. If the tables are cached (have been initialised before) in the connection, then loading is quick. Use TLptsConnection.clearCachedTablesAndColumns() to clear the cache if the tables have changed.

Example :


 TLptsStatement statement = new TLptsStatement(connection,XLptsDBTypeOfStatementType.SELECT);
 if ((statement.getTableTypesView()&TLptsFactoryStatement.TABLE_TYPE_SYSTEM)!=0)
  initTablesAndColumns(statement.getTableTypesView()|TLptsFactoryStatement.TABLE_TYPE_SYSTEM);

 

Parameters:
tableTypes - valid types are ORed combinations of the following: TLptsFactortStatement.TABLE_TYPE_USER TLptsFactortStatement.TABLE_TYPE_VIEW TLptsFactortStatement.TABLE_TYPE_SYSTEM TLptsFactortStatement.TABLE_TYPE_OTHER TLptsFactortStatement.TABLE_TYPE_TEMP

interruptExecution

public void interruptExecution()
Interrupts current statement execution.

Thread Safe : Yes

Spawns its own Thread : No

May Return NULL : N/A

Notes :

Example :

 ...

 private class RowSetListener implements ILptsFactoryRowSetListener
 {
   public void rowEvent(TLptsRowEvent rowEvent)
   {
     if(rowEvent.getEventType()==TLptsRowEvent.EVENT_TYPE.EXECUTION_INTERRUPTED)
     {
        System.out.println("Processing was interrupted on this Statement!"); // interruptExecution was called externally
     }
   }
   public boolean processNewRowSetRows(TLptsRowSetEvent rowSetEvent)
   {
     return true;
   }
 }
 


isClosed

public boolean isClosed()
                 throws java.sql.SQLException
Javadoc taken from Statement interface : Retrieves whether this Statement object has been closed. A Statement is closed if the method close has been called on it, or if it is automatically closed.

Specified by:
isClosed in interface java.sql.Statement
Returns:
true if this Statement object is closed; false if it is still open
Throws:
java.sql.SQLException - if a database access error occurs
Since:
1.6

isInterrupted

public boolean isInterrupted()
Tells us if the statement execution was interrupted.

Thread Safe : Yes

Spawns its own Thread : No

May Return NULL : N/A

Notes :

Example :

 ...

 private String statementId;
 private int desiredNumberOfProcessedRows;

 ...

 private class RowSetListener implements ILptsFactoryRowSetListener
 {
   public void rowEvent(TLptsRowEvent rowEvent)
   {
     if(rowEvent.getStatement().isInterrupted())
       return;                                   // throw it away!
     ...
   }
   public boolean processNewRowSetRows(TLptsRowSetEvent rowSetEvent)
   {
     return true;
   }
 }
 

Returns:
true if statement execution has been interrupted.

isPoolable

public boolean isPoolable()
                   throws java.sql.SQLException
Javadoc taken from Statement interface : Returns a value indicating whether the Statement is poolable or not.

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

See Also:
setPoolable(boolean)

isWrapperFor

public boolean isWrapperFor(java.lang.Class<?> iface)
                     throws java.sql.SQLException
Javadoc taken from Statement interface : Returns true if this either implements the interface argument or is directly or indirectly a wrapper for an object that does. Returns false otherwise. If this implements the interface then return true, else if this is a wrapper then return the result of recursively calling isWrapperFor on the wrapped object. If this does not implement the interface and is not a wrapper, return false. This method should be implemented as a low-cost operation compared to unwrap so that callers can use this method to avoid expensive unwrap calls that may fail. If this method returns true then calling unwrap with the same argument should succeed.

Specified by:
isWrapperFor in interface java.sql.Wrapper
Parameters:
iface - a Class defining an interface.
Returns:
true if this implements the interface or directly or indirectly wraps an object that does.
Throws:
java.sql.SQLException - if an error occurs while determining whether this is a wrapper for an object with the given interface.
Since:
1.6

resetAllTablesAndColumns

public void resetAllTablesAndColumns()
Deselects all tables and columns for the current statement.

Thread Safe : Yes

Spawns its own Thread : No

May Return NULL : N/A

Notes :

Example :


 //Create statement, select multiple columns, process etc..
 ...
 // This sets the tables and column of this data source to DESELECTED.
 // That means that no columns or tables will appear in the select SQL statement.
 statement.resetAllTablesAndColumns();
 ...
 


setCursorName

public void setCursorName(java.lang.String name)
                   throws java.sql.SQLException
Javadoc taken from Statement interface : Sets the SQL cursor name to the given String, which will be used by subsequent Statement object execute methods. This name can then be used in SQL positioned update or delete statements to identify the current row in the ResultSet object generated by this statement. If the database does not support positioned update/delete, this method is a noop. To insure that a cursor has the proper isolation level to support updates, the cursor's SELECT statement should have the form SELECT FOR UPDATE. If FOR UPDATE is not present, positioned updates may fail.

Note: By definition, the execution of positioned updates and deletes must be done by a different Statement object than the one that generated the ResultSet object being used for positioning. Also, cursor names must be unique within a connection.

Specified by:
setCursorName in interface java.sql.Statement
Parameters:
name - the new cursor name, which must be unique within a connection
Throws:
java.sql.SQLException - if a database access error occurs or this method is called on a closed Statement
java.sql.SQLFeatureNotSupportedException - if the JDBC driver does not support this method

setEscapeProcessing

public void setEscapeProcessing(boolean enable)
                         throws java.sql.SQLException
Javadoc taken from Statement interface : Sets escape processing on or off. If escape scanning is on (the default), the driver will do escape substitution before sending the SQL statement to the database.

Note: Since prepared statements have usually been parsed prior to making this call, disabling escape processing for PreparedStatements objects will have no effect.

Specified by:
setEscapeProcessing in interface java.sql.Statement
Parameters:
enable - true to enable escape processing; false to disable it
Throws:
java.sql.SQLException - if a database access error occurs or this method is called on a closed Statement

setFetchDirection

public void setFetchDirection(int direction)
                       throws java.sql.SQLException
Javadoc taken from Statement interface : Gives the driver a hint as to the direction in which rows will be processed in ResultSet objects created using this Statement object. The default value is ResultSet.FETCH_FORWARD.

Note that this method sets the default fetch direction for result sets generated by this Statement object. Each result set has its own methods for getting and setting its own fetch direction.

Specified by:
setFetchDirection in interface java.sql.Statement
Parameters:
direction - the initial direction for processing rows
Throws:
java.sql.SQLException - if a database access error occurs, this method is called on a closed Statement or the given direction is not one of ResultSet.FETCH_FORWARD, ResultSet.FETCH_REVERSE, or ResultSet.FETCH_UNKNOWN
Since:
1.2
See Also:
getFetchDirection()

setFetchSize

public void setFetchSize(int rows)
                  throws java.sql.SQLException
Javadoc taken from Statement interface : 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 ResultSet objects genrated by this Statement. If the value specified is zero, then the hint is ignored. The default value is zero.

Specified by:
setFetchSize in interface java.sql.Statement
Parameters:
rows - the number of rows to fetch
Throws:
java.sql.SQLException - if a database access error occurs, this method is called on a closed Statement or the condition rows >= 0 is not satisfied.
Since:
1.2
See Also:
getFetchSize()

setMaxFieldSize

public void setMaxFieldSize(int max)
                     throws java.sql.SQLException
Javadoc taken from Statement interface : Sets the limit for the maximum number of bytes that can be returned for character and binary column values in a ResultSet object produced by this Statement object.

This limit applies only to BINARY, VARBINARY, LONGVARBINARY, CHAR, VARCHAR, NCHAR, NVARCHAR, LONGNVARCHAR 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 column size limit in bytes; zero means there is no limit
Throws:
java.sql.SQLException - if a database access error occurs, this method is called on a closed Statement or the condition max >= 0 is not satisfied
See Also:
getMaxFieldSize()

setMaxRows

public void setMaxRows(int max)
                throws java.sql.SQLException
Javadoc taken from Statement interface : Sets the limit for the maximum number of rows that any ResultSet object generated by this Statement object can contain to the given number. 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 there is no limit
Throws:
java.sql.SQLException - if a database access error occurs, this method is called on a closed Statement or the condition max >= 0 is not satisfied
See Also:
getMaxRows()

setObject

public void setObject(int i,
                      java.lang.Object obj,
                      int sqlType)
Sets an object for substitution at runtime (replaces the ? in the Statement).

Thread Safe : Yes

Spawns its own Thread : No

May Return NULL : No

Notes :
This function is normally used at runtime for substituting dynamic objects into the SQL string, so that
they are used for processing the statement.
This version of setObject also allows for the setting of objects during instantiation of the TLptsStatement object.
This is done so that charsets can be supported through objects. Extended characters in SQL strings do not normally
function, so they need to added to the string through the setObject mechanism.
Obviously this can only be used with setSqlStatementUser as shown below.

In dynamic resultset processing, this mechanism is still in affect, but care needs to be taken with the indexing.

Example :

 // Sql code : "SELECT customer.* FROM customer WHERE customer.name = ?"
 ...
 TLptsStatement statement = new TLptsStatement(connection, XLptsDBTypeOfStatementType.SELECT);
 statement.setSqlStatementUser("SELECT [testTable].[ID] FROM [testTable] WHERE [testTable].[Occupation] <> ?");
 statement.setSqlStatementModified(true);

 statement.setObject(1,"ΟΙΚΙΑΚΑ", Types.NVARCHAR);

 statement.setTitle(columnName);
 TLptsFactoryStatement.createNewStatement(connection, statement);
 ...

 

Parameters:
i - is the index to substitute the questionmark in the prepare statement. 1 based, not 0.
obj - is the object to be set in the place of the questionmark.
sqlType - The SQL type of the object

setPoolable

public void setPoolable(boolean poolable)
                 throws java.sql.SQLException
Javadoc taken from Statement interface : Requests that a Statement be pooled or not pooled. The value specified is a hint to the statement pool implementation indicating whether the applicaiton wants the statement to be pooled. It is up to the statement pool manager as to whether the hint is used.

The poolable value of a statement is applicable to both internal statement caches implemented by the driver and external statement caches implemented by application servers and other applications.

By default, a Statement is not poolable when created, and a PreparedStatement and CallableStatement are poolable when created.

Specified by:
setPoolable in interface java.sql.Statement
Parameters:
poolable - requests that the statement be pooled if true and that the statement not be pooled if false

Throws:
java.sql.SQLException - if this method is called on a closed Statement

Since:
1.6

setPrimaryStatement

public void setPrimaryStatement(java.lang.String primaryStatementId,
                                boolean isSubstituteValueIntoSQLString)
Sets the primary statement for the current statement.

Thread Safe : Yes

Spawns its own Thread : No

May Return NULL : N/A

Notes :
This function is always accompanied by addPrimaryRelationship(int, int[], java.lang.String).
Together these functions specify a link or relationship between two statements.
The statement that calls these functions is the dynamic statement, which means that it is executed with every row
of the primary statement, taking the values specified from the primary statement's current row and substituting
them into the current statement and then execute the resultset.
In the example below we have 3 statements, namely Customers, Account and transactions. Customer is the top primary
and feeds data to account. For every account of the current customer, data is fed to the transactions so that we have
a 3 level dynamic statement relationship. There is no limit to the number of levels we can declare and execute.
This brings about one or many rowsets per customer for accounts, and one or many rowsets per account for transactions.
So in the end there is a tree or rowsets built, with the customer statement as the top level.
Each row comes down to the application with identification as to its statement, rowset and own id. The application can
then easily map the rows to a hierarchy structure (as shown in TLptsRowEvent.getRowObjectList()).

Example :

 ...
  // first we create the customer, account and transaction statements. Then we dynamically link them.
  // once they are linked, dbJAPI will process the hole structure and provide each record, one at a time, to the application
 // through the listener, with reference to its position in the structure. The application can then process the records as
 // required, with the correct structure. (like the data view window does TLptsViewDataDialog)

  TLptsStatement customerStatement, transStatement, itemStatement;

  ////////////////////////////////// CUSTOMER  ////////////////////////////////////

  // contains all the tables and columns of the connection. We need to select some or input a SQL string manually
  customerStatement = new TLptsStatement(connection,XLptsDBTypeOfStatementType.SELECT);
  customerStatement.setTitle("CUSTOMERS");
  // the quotations are for ODBC
  customerStatement.setSqlDatabaseFormat(XLptsDBSqlDatabaseFormat.DEFAULT_MYSQL);

  XLptsDBStatementTableType table = customerStatement.getTableItemByName("CUSTOMERS");
  table.setSelected(true); // selecting one table only, with all its columns
  customerStatement.setSelectOnAllColumns(table.getTableName(), true);

  // make sure this is not processed as we are waiting for the dynamic statements below to be created.
  customerStatement.setExecutable(false);
  TLptsFactoryStatement.createNewStatement(connection, customerStatement);

  ////////////////////////////////// ACCOUNT  ////////////////////////////////////

  accountStatement = new TLptsStatement(connection,XLptsDBTypeOfStatementType.SELECT);
  accountStatement.setTitle("TRANSACTIONS");
  accountStatement.setSqlDatabaseFormat(XLptsDBSqlDatabaseFormat.DEFAULT_MYSQL);

  table = accountStatement.getTableItemByName("TRANSACTIONS");
  table.setSelected(true); // selecting one table only, with all its columns
  accountStatement.setSelectOnAllColumns(table.getTableName(), true);  // select all the columns and the select statement SQL string will be created automatically.

  // relate this statement to the customer statement (this means that 'customer' will feed the data to this statement for every record of 'customer' to regenerate this statement every time)
  accountStatement.setPrimaryStatement(customerStatement.getId(),false);  // false means that we do not want static string substitution (uses the setObject of Statement)
  accountStatement.addPrimaryRelationship(2,new int[] {1}, TLptsFactoryStatement.OPERATION_EQUAL); // column 2 in this statement is related to column 1 in customer
                                                                                                   // certain operations allow for many indexes (like IN and BETWEEN)

  // make sure this is not processed as we are waiting for the dynamic statement below to be created.
  accountStatement.setExecutable(false);
  TLptsFactoryStatement.createNewStatement(connection, accountStatement);

  ////////////////////////////////// TRANSACTION  ////////////////////////////////////

  transStatement = new TLptsStatement(connection,XLptsDBTypeOfStatementType.SELECT);
  transStatement.setTitle("TRANSACTIONS");
  transStatement.setSqlDatabaseFormat(XLptsDBSqlDatabaseFormat.DEFAULT_MYSQL);

  table = transStatement.getTableItemByName("TRANSACTIONS");
  table.setSelected(true); // selecting one table only, with all its columns
  transStatement.setSelectOnAllColumns(table.getTableName(), true);  // select all the columns and the select statement SQL string will be created automatically.

  // relate this statement to the account statement (this means that 'account' will feed the data to this statement for every record of 'account' to regenerate this statement every time)
  transStatement.setPrimaryStatement(accountStatement.getId(),false);  // false means that we do not want static string substitution (false uses the setObject of Statement)
  transStatement.addPrimaryRelationship(2,new int[] {1}, TLptsFactoryStatement.OPERATION_EQUAL); // column 2 in this statement is related to column 1 in account
                                                                                                 // certain operations allow for many indexes (like IN and BETWEEN)

  // this statement can be processed now that all the statements are ready and created. This will execute the others dynamically
  transStatement.setExecutable(false);
  TLptsFactoryStatement.createNewStatement(connection, transStatement);
 ...
 

Parameters:
primaryStatementId - This is the id of the statement that is the primary to this dynamic
isSubstituteValueIntoSQLString - is true if we want to substitute '?' with the appropriate string in the SQL statement

setQueryTimeout

public void setQueryTimeout(int seconds)
                     throws java.sql.SQLException
Javadoc taken from Statement interface : Sets the number of seconds the driver will wait for a Statement object to execute to the given number of seconds. If the limit is exceeded, an SQLException is thrown. A JDBC driver must apply this limit to the execute, executeQuery and executeUpdate methods. JDBC driver implementations may also apply this limit to ResultSet methods (consult your driver vendor documentation for details).

Specified by:
setQueryTimeout in interface java.sql.Statement
Parameters:
seconds - the new query timeout limit in seconds; zero means there is no limit
Throws:
java.sql.SQLException - if a database access error occurs, this method is called on a closed Statement or the condition seconds >= 0 is not satisfied
See Also:
getQueryTimeout()

setSelectOnAllColumns

public void setSelectOnAllColumns(java.lang.String tableName,
                                  boolean isSelect)
Sets all the columns for a specific table to be SELECTED or NOT in the SQL statement.

Thread Safe : Yes

Spawns its own Thread : No

May Return NULL : N/A

Notes :

Example :


  customerStatement = new TLptsStatement(connection,XLptsDBTypeOfStatementType.SELECT);
  customerStatement.setTitle("CUSTOMERS");

  // the quotations are for MySQL
  customerStatement.setSqlDatabaseFormat(XLptsDBSqlDatabaseFormat.DEFAULT_MYSQL);

  XLptsDBStatementTableType table = customerStatement.getTableItemByName("CUSTOMERS");
  table.setSelected(true); // selecting one table only, with all its columns
  customerStatement.setSelectOnAllColumns(table.getTableName(), true);

 // dbJAPI automatically formats the SQL statement string so that it is ready for creation and execution.
  TLptsFactoryStatement.createNewStatement(connection, customerStatement);
 ...
 

Parameters:
tableName - the name of the specific table
isSelect - set true to set the columns selected or false to unselect

setSqlDatabaseFormat

public void setSqlDatabaseFormat(XLptsDBSqlDatabaseFormat value)
Sets the quotation format for current statement.

Thread Safe : Yes

Spawns its own Thread : No

May Return NULL : No

Notes :

Example :


 TLptsStatement customerStatement;

 ////////////////////////////////// CUSTOMER  ////////////////////////////////////

 // contains all the tables and columns of the connection. We need to select some or input a SQL string manually
 customerStatement = new TLptsStatement(connection,XLptsDBTypeOfStatementType.SELECT);
 customerStatement.setTitle("CUSTOMERS");
 // the quotations are for ODBC
 customerStatement.setSqlDatabaseFormat(XLptsDBSqlDatabaseFormat.DEFAULT_MYSQL);

 XLptsDBStatementTableType table = customerStatement.getTableItemByName("CUSTOMERS");
 table.setSelected(true); // selecting one table only, with all its columns
 customerStatement.setSelectOnAllColumns(table.getTableName(), true);

 // make sure this is not processed as we are waiting for the dynamic statements below to be created.
 customerStatement.setExecutable(false);
 TLptsFactoryStatement.createNewStatement(connection, customerStatement);

 

Overrides:
setSqlDatabaseFormat in class XLptsDBStatementType
Parameters:
value - One of the following: ORACLE_NO_QUOTATION, DEFAULT_ODBC, DEFAULT_MS_SQL, DEFAULT_POSTGRES, DEFAULT_MYSQL

setSqlStatementExtension

public void setSqlStatementExtension(java.lang.String value)
This is an override of the XLptsDBStatementType setSqlStatementExtension.
This is purely for documentation purposes.
This function is used to set the extension of an automatically build string.
It is not used when the SQL string has been manually updated setSqlStatementUser(java.lang.String) & XLptsDBStatementType.setSqlStatementModified(boolean).
Note : all quotations required by the relative SQL should be included.
Example : setSqlStatementExtension("ORDER BY \"CLIENTS.ID\"");

Overrides:
setSqlStatementExtension in class XLptsDBStatementType
Parameters:
value - The String to go on the end of the generated string. Normally contains and ORDER BY or SORT clause, which could not be generated.

setSqlStatementUser

public void setSqlStatementUser(java.lang.String value)
This is an override of XLptsDBStatementType.setSqlStatementUser(String).
This is done so that the setObjects on the statement can be cleared with a new SQL string.

Overrides:
setSqlStatementUser in class XLptsDBStatementType
Parameters:
value - The new user SQL statement.

setTitle

public void setTitle(java.lang.String value)
Overrides of function from XLptsDBStatementType : Sets the title of the statement.

This function may not set the desired title if the title already exists in the statement list.
This function will incrementally add a number to the end of the desired name, until it finds a unique name.

Overrides:
setTitle in class XLptsDBStatementType
Parameters:
value - The desired title of the statement.

unwrap

public <T> T unwrap(java.lang.Class<T> iface)
         throws java.sql.SQLException
Javadoc taken from Statement interface : Returns an object that implements the given interface to allow access to non-standard methods, or standard methods not exposed by the proxy.

If the receiver implements the interface then the result is the receiver or a proxy for the receiver. If the receiver is a wrapper and the wrapped object implements the interface then the result is the wrapped object or a proxy for the wrapped object. Otherwise return the the result of calling unwrap recursively on the wrapped object or a proxy for that result. If the receiver is not a wrapper and does not implement the interface, then an SQLException is thrown.

Specified by:
unwrap in interface java.sql.Wrapper
Parameters:
iface - A Class defining an interface that the result must implement.
Returns:
an object that implements the interface. May be a proxy for the actual implementing object.
Throws:
java.sql.SQLException - If no object found that implements the interface
Since:
1.6

zaCLI

public void zaCLI(XLptsDBStatementColumnType sct)
Obfuscated as it is not required by the application interface.


zaTLI

public void zaTLI(XLptsDBStatementTableType stt)
Obfuscated as it is not required by the application interface.


zaUIDLI

public void zaUIDLI(XLptsDBUpInsDelType uidt)
Obfuscated as it is not required by the application interface.


zcUIDLI

public void zcUIDLI()
Obfuscated as it is not required by the application interface.


zgCI

public int zgCI(XLptsDBStatementColumnType column)
Obfuscated as it is not required by the application interface.


zgOL

public java.util.List<com.lapetus_ltd.api.db.control.TLptsStatement.SetObjectClass> zgOL()
Obfuscated.


zgSSS

public java.lang.String zgSSS()
Obfuscated as it is not required by the application interface.


ziSS

public boolean ziSS()
Obfuscated as it is not required by the application interface.


zpPR

public boolean zpPR()
Obfuscated as it is not required by the application interface.


zrc

public void zrc(XLptsDBStatementColumnType sct)
Obfuscated as it is not required by the application interface.


zrI

public void zrI()
Obfuscated as it is not required by the application interface.


zrTLI

public void zrTLI(XLptsDBStatementTableType stt)
Obfuscated as it is not required by the application interface.


zrUIDLI

public void zrUIDLI(XLptsDBUpInsDelType uidt)
Obfuscated as it is not required by the application interface.


zsOL

public void zsOL()
Obfuscated.


zsR

public void zsR(TLptsRowSet rowSet)
Obfuscated as it is not required by the application interface.


zsS

public void zsS(java.sql.Statement statement)
Obfuscated as it is not required by the application interface.


zsSS

public void zsSS(boolean setSub)
Obfuscated as it is not required by the application interface.


zsSSS

public void zsSSS(java.lang.String sql)
Obfuscated as it is not required by the application interface.



Copyright 2009,2010, Lapetus Systems Ltd. (All rights reserved)