com.adhi.adhij
Class DataAccessObject

java.lang.Object
  extended by com.adhi.adhij.DataAccessObject
All Implemented Interfaces:
java.io.Serializable

public abstract class DataAccessObject
extends java.lang.Object
implements java.io.Serializable

The Data Access Object. This class connects to the data server and executes queries.

Author:
DKRISHNA
See Also:
Serialized Form

Constructor Summary
DataAccessObject()
           
 
Method Summary
 void closeConnection()
          close the database connection
 RowSet createRowSet(java.sql.ResultSet rs)
          create a row set out of a result set
 java.sql.Statement createStatement()
          create a statement
 void finallyClose(java.sql.ResultSet result, java.sql.Statement stmt, java.lang.Exception exception)
          This is a clean up operation.
 java.sql.PreparedStatement getPreparedStmt(java.lang.String query)
          create a prepared statement using the connection
 void openConnection()
          opens the database connection
 void openConnection(java.lang.String dsJNDI)
          open a database connection using a jndi name of a data source
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DataAccessObject

public DataAccessObject()
Method Detail

closeConnection

public void closeConnection()
                     throws java.sql.SQLException
close the database connection

Throws:
java.sql.SQLException - when the connection cannot he closed

finallyClose

public void finallyClose(java.sql.ResultSet result,
                         java.sql.Statement stmt,
                         java.lang.Exception exception)
                  throws DataException
This is a clean up operation. it closes all the database resources (result set, statement and connection)

Parameters:
result - the result set
stmt - the statement
exception - if there is an exception already happened
Throws:
DataException - when the clean up operation fails

openConnection

public void openConnection()
                    throws java.lang.Exception
opens the database connection

Throws:
java.lang.Exception - if the database connection cannot be opened

openConnection

public void openConnection(java.lang.String dsJNDI)
                    throws DataException
open a database connection using a jndi name of a data source

Parameters:
dsJNDI - the JNDI name of a data source
Throws:
DataException - when the connection cannot be opened

createRowSet

public RowSet createRowSet(java.sql.ResultSet rs)
                    throws java.sql.SQLException
create a row set out of a result set

Parameters:
rs - the result set
Returns:
the rowset
Throws:
java.sql.SQLException - if the rowset cannot be created

getPreparedStmt

public java.sql.PreparedStatement getPreparedStmt(java.lang.String query)
                                           throws java.sql.SQLException
create a prepared statement using the connection

Parameters:
query - the query string
Returns:
the prepared statement
Throws:
java.sql.SQLException - when the prepared statement cannot be created

createStatement

public java.sql.Statement createStatement()
                                   throws java.sql.SQLException
create a statement

Returns:
the statement
Throws:
java.sql.SQLException - if the statement cannot be created