All Packages Class Hierarchy This Package Previous Next Index
Class dbgeneric.DatabaseAccess
java.lang.Object
|
+----dbgeneric.DatabaseAccess
- public class DatabaseAccess
- extends Object
- implements Serializable
Base class for database accessor classes.
Provides a set of common database functions.
These include making connections and running queries.
-
_con
- This use of a static ConnectionManager allows all the
extended classes to use the same pool of connections to the
database.
-
debug
-
-
queryStatement
-
-
DatabaseAccess()
- Constructor which loads properties in from the default file
called "db.properties".
-
DatabaseAccess(Properties)
- Constructor with Properties.
-
catchEx(Exception)
- General last ditch exception catcher.
-
connect()
- Gets a valid connection to the database from the Connection
Manager and stores it in _con.
-
disconnect()
- Puts our connection back into the ConnectionManager pool.
-
doUpdateQuery(String)
- Executes an update/insert query in the database.
Note we must be connect to the database before
making this call.
-
executeQuery(String)
- Executes a query in the database which returns a Resultset.
Note we must be connect to the database before
making this call.
-
getError()
- Gets the error string.
-
setError(String)
- Sets the error string.
_con
public Connection _con
- This use of a static ConnectionManager allows all the
extended classes to use the same pool of connections to the
database. This is very effecient. The only downside is that
it effectively prevents connections to multiple databases.
To achieve multiple databases, this class would have to be copied
to a different name and hence give multiple connection pools
queryStatement
public Statement queryStatement
debug
public static final boolean debug
DatabaseAccess
public DatabaseAccess()
- Constructor which loads properties in from the default file
called "db.properties".
This is only done on the first call of this constructor.
Later calls will use the existing connection pool.
DatabaseAccess
public DatabaseAccess(Properties props)
- Constructor with Properties.
Sets the values used to connect to the database to be different
via the user defined Properties.
Includes defining the proxy, registering the driver etc
setError
public void setError(String error)
- Sets the error string.
getError
public String getError()
- Gets the error string.
catchEx
public void catchEx(Exception e)
- General last ditch exception catcher.
Simply logs the error.
connect
public boolean connect()
- Gets a valid connection to the database from the Connection
Manager and stores it in _con.
disconnect
public boolean disconnect() throws SQLException
- Puts our connection back into the ConnectionManager pool.
doUpdateQuery
public synchronized boolean doUpdateQuery(String dbQuery)
- Executes an update/insert query in the database.
Note we must be connect to the database before
making this call.
executeQuery
public synchronized ResultSet executeQuery(String query) throws SQLException
- Executes a query in the database which returns a Resultset.
Note we must be connect to the database before
making this call.
This call is synchronised to limit the number of executing statements
to one per DatabaseAccess instantiation.
All Packages Class Hierarchy This Package Previous Next Index