com.fdsapi
Class DataAccessBase

java.lang.Object
  |
  +--com.fdsapi.DataAccessBase
All Implemented Interfaces:
DataAccess
Direct Known Subclasses:
DataAccessClient, DataAccessJ2EE

public abstract class DataAccessBase
extends java.lang.Object
implements DataAccess

This class is used to connect to a database server and execute SQL against that server. This class can be used in any Java code including EJB's.

Some background information about the java.sql.Statement class Statement - can perform selects, updates, deletes, insert and call stored procs. If you want to use IN parameters (i.e. ?) then you should use PreparedStatement and if you want to use OUT parameters you should use CallableStatement.

All of the following will close any of the statements open result sets.

Statement.executeQuery() - returns a single result set.
Statement.executeUpdate() - performs inserts, deletes, updates and DDL. returns number of rows affected.
Statement.execute() - can return multiple result sets or update counts.
Statement.close() - automatically closes any open ResultSet. Statements are closed automatically by the garbage collector. However it is good practice to close them explicitly.

Connections, ResultSets and Statements are all automatically closed by the garbage collector, however it is good practice to close them explicitly.



View Code


Field Summary
protected  java.sql.Connection connection
           
protected  java.sql.ResultSet resultSet
           
protected  java.sql.Statement statement
           
 
Constructor Summary
DataAccessBase()
           
 
Method Summary
 void close()
           
 void closeConnection()
           
 void closeResultSet()
           
 void closeStatement()
           
 boolean connectionIsClosed()
           
protected  java.sql.Statement createStatement()
           
protected  java.sql.ResultSet executeQuery(java.lang.String query)
           
 int executeUpdate(java.lang.String sql)
           
 java.lang.String getDataSourceName()
           
 java.sql.ResultSet getResultSet(java.lang.String queryCommand)
           
 ResultSetConverter getResultSetConverter(java.lang.String query)
           
 void setDataSourceName(java.lang.String dataSourceName)
           
protected  Monitor start(java.lang.String locator)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.fdsapi.DataAccess
createInstance, getConnection
 

Field Detail

connection

protected java.sql.Connection connection

statement

protected java.sql.Statement statement

resultSet

protected java.sql.ResultSet resultSet
Constructor Detail

DataAccessBase

public DataAccessBase()
Method Detail

setDataSourceName

public void setDataSourceName(java.lang.String dataSourceName)
Specified by:
setDataSourceName in interface DataAccess

getDataSourceName

public java.lang.String getDataSourceName()
Specified by:
getDataSourceName in interface DataAccess

createStatement

protected java.sql.Statement createStatement()
                                      throws java.sql.SQLException
java.sql.SQLException

start

protected Monitor start(java.lang.String locator)

executeQuery

protected java.sql.ResultSet executeQuery(java.lang.String query)
                                   throws java.sql.SQLException
java.sql.SQLException

close

public void close()
           throws java.sql.SQLException
Specified by:
close in interface DataAccess
java.sql.SQLException

closeConnection

public void closeConnection()
                     throws java.sql.SQLException
Specified by:
closeConnection in interface DataAccess
java.sql.SQLException

connectionIsClosed

public boolean connectionIsClosed()
                           throws java.sql.SQLException
Specified by:
connectionIsClosed in interface DataAccess
java.sql.SQLException

closeResultSet

public void closeResultSet()
                    throws java.sql.SQLException
Specified by:
closeResultSet in interface DataAccess
java.sql.SQLException

closeStatement

public void closeStatement()
                    throws java.sql.SQLException
Specified by:
closeStatement in interface DataAccess
java.sql.SQLException

getResultSet

public java.sql.ResultSet getResultSet(java.lang.String queryCommand)
                                throws java.sql.SQLException
Specified by:
getResultSet in interface DataAccess
java.sql.SQLException

getResultSetConverter

public ResultSetConverter getResultSetConverter(java.lang.String query)
                                         throws java.sql.SQLException
Specified by:
getResultSetConverter in interface DataAccess
java.sql.SQLException

executeUpdate

public int executeUpdate(java.lang.String sql)
                  throws java.sql.SQLException
Specified by:
executeUpdate in interface DataAccess
java.sql.SQLException