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
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
connection
protected java.sql.Connection connection
statement
protected java.sql.Statement statement
resultSet
protected java.sql.ResultSet resultSet
DataAccessBase
public DataAccessBase()
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