Database
Class SFDataBase

java.lang.Object
  |
  +--Database.SFDataBase
All Implemented Interfaces:
Database.dbconstants, BaseClasses.Persistent, BaseClasses.SFConstants

public class SFDataBase
extends java.lang.Object
implements BaseClasses.Persistent, BaseClasses.SFConstants, Database.dbconstants


Field Summary
Fields inherited from interface Database.dbconstants
DUPLICATE_KEY, EXISTS, FAIL, GENERAL_FAILURE, MORE_ROWS, NO_MORE_RESULTS, NO_MORE_ROWS, NOT_EXISTS, SUCCEED
Method Summary
 int addRow(java.lang.String columnNames, java.lang.String tableName, java.lang.String formatString, java.util.Vector container)
          Adds new row to the database table.
 int affectedRowCount()
          Returns the number of rows affected by preceding UPDATE or DELETE operation
 int beginTransaction()
          Begins transaction.
 int commitTransaction()
          Commits transaction.
 java.lang.String currentDatabase()
          Returns the name of the current schema.
 int deleteRowFromTable(java.lang.String tableName, java.lang.String searchCondition)
          Deletes rows from the table according to the search condition.
 int execSQL(java.lang.String sqlStatement)
          Executes SQL statement
 int existsRow(java.lang.String searchCondition, java.lang.String tableName)
          Checks row for existence.
 int existsTable(java.lang.String tableName)
          Checks table for existence
static Database.SFDataBase getInstance()
          Returns an instance of SFDataBase object.
 java.util.Vector getRows(java.lang.String columnNames, java.lang.String tableName, java.lang.String searchCondition, java.lang.String formatString)
          Returns rows from the table.
 int rollbackTransaction()
          Rolls back transaction.
 int rowCountInTable(java.lang.String tableName, java.lang.String searchCondition)
          Returns the number of rows in the table
 int updateRow(java.lang.String columnNames, java.lang.String tableName, java.lang.String searchCondition, java.lang.String formatString, java.util.Vector container)
          Updates rows in the database table.
 int useDatabase(java.lang.String databaseName)
          Sets current schema.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Method Detail

getInstance

public static Database.SFDataBase getInstance(String connection)
Returns an instance of SFDataBase object for the given connection. Connections are created by the Scribe Administrator via the Server Administrator program.

Parameters:
connection - name of the connection
Returns:
SFDataBase object

beginTransaction

public int beginTransaction()
Begins transaction. If the database engine does not support explicit beginning of transaction, this method has no effect.

Returns:
SUCCEED or FAIL

commitTransaction

public int commitTransaction()
Commits transaction. If transactions are nested, only the outermost commit is actually executed.

Returns:
SUCCEED or FAIL

rollbackTransaction

public int rollbackTransaction()
Rolls back transaction. If transactions are nested, rolls back to the top BEGIN TRANSACTION statement from any level of nesting.

Returns:
SUCCEED or FAI

useDatabase

public int useDatabase(java.lang.String databaseName)
Sets current schema.

If this method is used from a user-written function, the database must be set to the original schema before the function exits.

Parameters:
databaseName - name of the schema to switch to.
Returns:
SUCCEED or FAIL

currentDatabase

public java.lang.String currentDatabase()
Returns the name of the current schema.
 
Returns:
The name of the current schema

existsRow

public int existsRow(java.lang.String searchCondition,
                     java.lang.String tableName)
Checks row for existence.

Parameters:
searchCondition - String with WHERE clause, without the "WHERE" keyword
tableName - name of the table
Returns:
EXISTS, NOT_EXISTS or FAIL

rowCountInTable

public int rowCountInTable(java.lang.String tableName,
                           java.lang.String searchCondition)
Returns the number of rows in the table

Parameters:
tableName - name of the table
searchCondition - String with WHERE clause
Returns:
number of rows matching the search condition, or -1 if fails

deleteRowFromTable

public int deleteRowFromTable(java.lang.String tableName,
                              java.lang.String searchCondition)
Deletes rows from the table according to the search condition.

Parameters:
tableName - name of the table
searchCondition - WEHERE clause without the "WHERE" keyword
Returns:
SUCCEED or FAIL

execSQL

public int execSQL(java.lang.String sqlStatement)
Executes SQL statement

Parameters:
sqlStatement - SQL statement to execute
Returns:
SUCCEED or FAIL

existsTable

public int existsTable(java.lang.String tableName)
Checks existence of table

Parameters:
tableName - name of the table
Returns:
EXISTS, NOT_EXISTS or FAIL

affectedRowCount

public int affectedRowCount()
Returns the number of rows affected by preceding DELETE operation

Returns:
number of affected rows

getRows

public java.util.Vector getRows(java.lang.String columnNames,
                                java.lang.String tableName,
                                java.lang.String searchCondition,
                                java.lang.String formatString)
Returns rows from the table. The rows are fetched according to the search condition, and are returned in a form of a Vector with DataContainer objects; each DataContainer corresponds to one returned row and stores DataWrapper objects - one for each column. Internally, this method generates a SELECT statement formatted for execution by the JDBC Statement object.

 

The following format codes are valid:
 
  • "INT" for columns of 4-byte INT type
  • "SMALL" for columns of 2-byte INT type
  • "TINY" for columns of 1-byte INT type
  • "FLT8" for columns of DOUBLE type
  • "MONEY" for columns of MONEY type
  • "OBJECT" for columns of BLOB type storing serialized Java objects
  • "BLOB" for columns of BLOB type storing binary data
  • "LOGICAL" for columns of boolean type
  • "CHAR" for columns of CHAR(1) and VARCHAR(1) type
  • "STRING" for columns of CHAR and VARCHAR type
 
Parameters:
columnNames - comma-separated list of column names
tableName - name of the table
searchCondition - WHERE clause
formatString - list of comma-separated format tags

 

Returns:
Vector of DataContainer objects (can be empty if no rows were returned), or null if the call failed

addRow

public int addRow(java.lang.String columnNames,
                  java.lang.String tableName,
                  java.lang.String formatString,
                  java.util.Vector container)
Adds new row to the database table.

Internally, this method generates an INSERT statement formatted for execution by the JDBS PreparedStatement object.

Parameters:
columnNames - String of column names separated by commas
tableName - String with the name of the table
formatString - String of format tags separated by commas
container - Vector with DataWrapper objects to form the new row (see DataContainer class)
Returns:
SUCCEED or FAIL

updateRow

public int updateRow(java.lang.String columnNames,
                     java.lang.String tableName,
                     java.lang.String searchCondition,
                     java.lang.String formatString,
                     java.util.Vector container)
Updates rows in the database table.

Internally, this method generates an UPDATE statement formatted for execution by the JDBS PreparedStatement object.

Parameters:
columnNames - String of column names separated by commas
tableName - String with the name of the table
formatString - String of format tags separated by commas
container - Vector with DataWrapper objects to update the row (see DataContainer class)
Returns:
SUCCEED or FAIL