sky.engine.connector
Class DatabaseConnector

java.lang.Object
  extended bysky.engine.connector.DatabaseConnector

public class DatabaseConnector
extends java.lang.Object

DatabaseConnector is a layer between SAF Forms and back-end relational database. SAF Forms can contain SQL queries with special tags which are used to automatically map and bind form fields to back-end relational schema. DatabaseConnector serves as the driver for this binding and mapping of form fields to relational schema. An instance of DatabaseConnector contains a handle to a connection pool. Connections are obtained from this connection pool as and when needed. In order for the mapping and binding to take place effectively a SAF based Form must also register itself with the DatabaseConnector. See SAF documentation (http://www.interec.net/SAF) for more details.

$RCSfile: DatabaseConnector.java,v $
$Revision: 1.5 $, $Date: 2005/04/24 03:14:01 $


Field Summary
protected  DBConnection _conn
          Database connection handle
protected  java.lang.String _driver
          JDBC driver for this connector.
protected  Form _form
          SAF Form processor that is using this connector.
protected  DBPool _pool
          Database connection pool handle.
protected  java.util.ArrayList _sqls
          SQL statements that need to be processed.
protected  java.lang.String _url
          JDBC URL for this connector.
 
Constructor Summary
DatabaseConnector(DBPool pool, Form form)
          Constructor
 
Method Summary
 int addQuery(java.lang.String sql)
          SAF based forms use this function to register SQL queries containing special tags for binding and mapping of field data to back-end relational schema.
 void destroy()
          clear all state information.
 DBRowIterator executeQuery(int qid)
          Execute the SELECT query identified with a specific id.
 int executeUpdate(int qid)
          Execute an INSERT or UPDATE query
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_conn

protected DBConnection _conn
Database connection handle


_pool

protected DBPool _pool
Database connection pool handle.


_driver

protected java.lang.String _driver
JDBC driver for this connector.


_url

protected java.lang.String _url
JDBC URL for this connector.


_sqls

protected java.util.ArrayList _sqls
SQL statements that need to be processed.


_form

protected Form _form
SAF Form processor that is using this connector.

Constructor Detail

DatabaseConnector

public DatabaseConnector(DBPool pool,
                         Form form)
                  throws Message
Constructor

Parameters:
pool - Database connection pool from which a connection will be obtained.
form - SAF Form which is going to use this connector.
Throws:
Messages - in case any connection pool status or error conditions arise.
Message
Method Detail

addQuery

public int addQuery(java.lang.String sql)
             throws Message
SAF based forms use this function to register SQL queries containing special tags for binding and mapping of field data to back-end relational schema. Before a form can execute a query, it must add the query to the DatabaseConnector using this API.

Parameters:
sql - query that may contain SAF query tags.
Returns:
unique id of the query that was added. This id is then used by the form to execute the query.
Throws:
Message - is there are any error or status conditions to report.

executeQuery

public DBRowIterator executeQuery(int qid)
                           throws Message
Execute the SELECT query identified with a specific id.

Parameters:
qid - unique id of the query that was previously added.
Returns:
result row iterator.
Throws:
Message - if there are any error or status messages to report.

executeUpdate

public int executeUpdate(int qid)
                  throws Message
Execute an INSERT or UPDATE query

Parameters:
qid - unique id of a query that was previously added.
Throws:
Message - if there are any error or status conditions.

destroy

public void destroy()
clear all state information.