org.opentox.database
Class InHouseDB

java.lang.Object
  extended by org.opentox.database.InHouseDB
All Implemented Interfaces:
IDataBaseAccess

public final class InHouseDB
extends java.lang.Object
implements IDataBaseAccess

This is a class to manage access to the database behind the services. This class adopts the Singleton Design Pattern (see this article for details ). Only one object of this class can be created! The access point pf this class is INSTANCE and is the only object that can be created. The contructor of InHouseDB is private and cannot be accessed from other classes and what is more, InHouseDB cannot be subclassed. The interface IDataBaseAccess provides an API for classes used to access certain tables of the database such as the Models' and the Users' ones.

Version:
1.3.3 (Last update: Dec 28, 2009)
Author:
OpenTox - http://www.opentox.org/, Sopasakis Pantelis, Sarimveis Harry

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.opentox.interfaces.IDataBaseAccess
IDataBaseAccess.CreateTable, IDataBaseAccess.Registration, IDataBaseAccess.Removal
 
Field Summary
protected static java.sql.Connection connection
          Static Connection to the databse.
private static java.lang.String DB_PASSWORD
           
private static java.lang.String DB_USER
           
static InHouseDB INSTANCE
          Thread-safe instantiation of the database through a final instance of it.
private static InHouseDB instanceOfThis
           
 
Fields inherited from interface org.opentox.interfaces.IDataBaseAccess
DATABASENAME, DB_URL, DRIVER
 
Constructor Summary
private InHouseDB()
          Database Constructor.
 
Method Summary
 void close()
           
private static void createDataBase()
          If the database does not exist, it is created.
private  void getConnection()
          Establishes a connection to the database.
private static InHouseDB getInstance()
           
private  void loadDriver()
          Loads the Driver that is used to establish a new connection.
private  void loadTables()
          Load the tables in the database.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DB_USER

private static final java.lang.String DB_USER
See Also:
Constant Field Values

DB_PASSWORD

private static final java.lang.String DB_PASSWORD
See Also:
Constant Field Values

connection

protected static java.sql.Connection connection
Static Connection to the databse.


instanceOfThis

private static InHouseDB instanceOfThis

INSTANCE

public static final InHouseDB INSTANCE
Thread-safe instantiation of the database through a final instance of it.

Constructor Detail

InHouseDB

private InHouseDB()
Database Constructor. Connects to the existing database or creates a new one if database doesn't exist.

Method Detail

getInstance

private static InHouseDB getInstance()

loadDriver

private void loadDriver()
Loads the Driver that is used to establish a new connection.


getConnection

private void getConnection()
Establishes a connection to the database.


loadTables

private void loadTables()
Load the tables in the database. If one or more tables do not exist, they are created ab-initio.


createDataBase

private static void createDataBase()
If the database does not exist, it is created.


close

public void close()