All Packages Class Hierarchy This Package Previous Next Index
Class tc.database.DatabaseManager
java.lang.Object
|
+----tc.database.DatabaseManager
- public class DatabaseManager
- extends Object
- implements ExceptionObserver
DatabaseManager
handles the communication with the database. A
new DatabaseManager
object is intended to be created for every
database connection (for every database user).
DatabaseManager
stores the user name and id and marker ids of
the user for whom the database is opened (via this manager). These attributes
are obtained during database opening and marker fetching and they are later
used to ensure that only data associated with this user is tampered via this
manager.
The interface ExceptionObserver
(namely the operation
exceptionOccured
) is implemented so that it closes the database.
This mechanism is used in exception situations.
- Version:
- 0.30, 1998/04/01
- Author:
- Antti Viljamaa, FRED development team
- See Also:
- ExceptionObserver
-
connectionDescriptor
- The connection descriptor for the database.
-
database
- The database.
-
databaseOpen
- Determines whether the database is open.
-
databaseStarted
- Determines whether the database was succesfully started.
-
databaseStartException
- The possible exception that occured upon a failed database start.
-
markerIDs
- Vector of marker ids of the user.
-
userID
- The user id (ssn) of the user.
-
userName
- The user name of the user.
-
DatabaseManager()
- Constructs a new DatabaseManager object and tries to start it.
-
closeDatabase()
- Closes the database.
-
createDataSet(String, boolean)
- Creates a new QueryDataSet and executes the specified query to fill it.
-
exceptionOccured(Exception)
- An exception has occured during message sending or receiving.
-
getConnectionDescriptor()
- Returns connection descriptor for the database.
-
getDatabase()
- Returns the database.
-
getDatabaseStartException()
- Gets the possible exception occured during database starting.
-
getMarkerIDs()
- Returns the marker ids of the user.
-
getUserID()
- Gets the user id.
-
getUserName()
- Gets the username.
-
isDatabaseOpen()
- Determines if the database is opened.
-
isDatabaseStarted()
- Determines whether the database is started.
-
isValidMarker(int)
- Determines if the specified marker is valid.
-
openDatabase(String, byte[])
- Opens the database and returns the account options associated with the
given
userName
.
-
runQuery(DatabaseQuery)
- Executes the given query.
-
setConnectionDescriptor(ConnectionDescriptor)
- Sets connection descriptor for the database.
-
setDatabaseOpen(boolean)
- Sets the flag that determines if the database is opened.
-
setDatabaseStarted(boolean)
- Sets the flag that determines whether the database is started.
-
setDatabaseStartException(Exception)
- Sets the possible exception occured during database starting.
-
setMarkerIDs(Vector)
- Sets the marker ids of the user.
-
setUserID(String)
- Sets the user id.
-
setUserName(String)
- Sets the username.
-
startDatabaseManager()
- Starts the database.
-
trunc(long)
- Truncates last three digits from a long integer.
database
private Database database
- The database.
databaseOpen
private boolean databaseOpen
- Determines whether the database is open.
databaseStarted
private boolean databaseStarted
- Determines whether the database was succesfully started.
databaseStartException
private Exception databaseStartException
- The possible exception that occured upon a failed database start.
markerIDs
private Vector markerIDs
- Vector of marker ids of the user.
userID
private String userID
- The user id (ssn) of the user. The key in the 'Worker' table.
userName
private String userName
- The user name of the user. The key in the 'UserAccount' table.
connectionDescriptor
private ConnectionDescriptor connectionDescriptor
- The connection descriptor for the database.
DatabaseManager
public DatabaseManager()
- Constructs a new DatabaseManager object and tries to start it. A
possible exception that occurs is stored and later thrown when the
openDatabase method is invoked.
- See Also:
- openDatabase
closeDatabase
public void closeDatabase() throws DataSetException, DatabaseAlreadyClosedException
- Closes the database.
exceptionOccured
public void exceptionOccured(Exception exception)
- An exception has occured during message sending or receiving.
We assume that connection to the client has terminated. Closes the
database.
This method is the implementation for ExceptionObserver interface.
- Parameters:
- exception - The exception that has occured.
- See Also:
- ExceptionObserver
getMarkerIDs
public Vector getMarkerIDs()
- Returns the marker ids of the user.
getUserID
public String getUserID()
- Gets the user id.
getUserName
public String getUserName()
- Gets the username.
isDatabaseOpen
public boolean isDatabaseOpen()
- Determines if the database is opened.
isDatabaseStarted
public boolean isDatabaseStarted()
- Determines whether the database is started.
openDatabase
public AccountOptionsMessage openDatabase(String userName,
byte passwd[]) throws Exception
- Opens the database and returns the account options associated with the
given
userName
. Checks that the given encrypted password
matches the one in the database.
- Parameters:
- userName - The user whose data is going to be examined (and
altered).
- passwd - The encrypted password of the user.
runQuery
public Object runQuery(DatabaseQuery query) throws ValidationException, DataSetException
- Executes the given query.
- Parameters:
- DatabaseQuery - The query to be executed.
- Returns:
- Object The query result.
getConnectionDescriptor
public ConnectionDescriptor getConnectionDescriptor()
- Returns connection descriptor for the database.
setConnectionDescriptor
public void setConnectionDescriptor(ConnectionDescriptor cd)
- Sets connection descriptor for the database.
getDatabase
protected Database getDatabase()
- Returns the database.
getDatabaseStartException
protected Exception getDatabaseStartException()
- Gets the possible exception occured during database starting.
isValidMarker
protected boolean isValidMarker(int markerid)
- Determines if the specified marker is valid. Marker id is valid if it is
found among the markers calculated for the user.
- Parameters:
- markerid - The marker id that is checked.
setDatabaseOpen
protected void setDatabaseOpen(boolean flag)
- Sets the flag that determines if the database is opened.
setDatabaseStarted
protected void setDatabaseStarted(boolean flag)
- Sets the flag that determines whether the database is started.
setUserID
protected void setUserID(String id)
- Sets the user id.
setUserName
protected void setUserName(String n)
- Sets the username.
createDataSet
private QueryDataSet createDataSet(String queryClause,
boolean updatable) throws DataSetException
- Creates a new QueryDataSet and executes the specified query to fill it.
- Parameters:
- queryClause - An SQL query as a string.
- updatable - Determines if the dataset to be created must be
updatable (used in insertion or deletion).
- Returns:
- QueryDataSet The created data set.
setDatabaseStartException
private void setDatabaseStartException(Exception e)
- Sets the possible exception occured during database starting.
setMarkerIDs
private void setMarkerIDs(Vector v)
- Sets the marker ids of the user.
startDatabaseManager
private void startDatabaseManager() throws DataSetException, ValidationException
- Starts the database.
trunc
static long trunc(long original)
- Truncates last three digits from a long integer.
- Parameters:
- original - The original value.
- Returns:
- long The truncated value.
All Packages Class Hierarchy This Package Previous Next Index