org.rimudb
Class Database

java.lang.Object
  extended by org.rimudb.Database

public class Database
extends java.lang.Object

This class manages connectivity to a specific Database.

Author:
Simon Ritchie

Constructor Summary
Database(DatabaseConfiguration databaseConfiguration, boolean validateXML)
          Create a Database.
 
Method Summary
 void connect(java.lang.String user, java.lang.String password)
          Connect to the database.
 Session createSession()
          Get a Session
 void disconnect()
          Disconnect from the database.
 void forceTableLoad()
          Force all the tables configured in the XML config file to be loaded.
 Table[] getAllTables()
          Return an array of all the AbstractTables that have been discovered with this Database.
 IConnectionManager getConnectionManager()
          Return the connection pool manager
 DatabaseConfiguration getDatabaseConfiguration()
          Return the DatabaseConfiguration.
 java.sql.Connection getDatabaseConnection()
          Get a connection.
 RimuDBDatabaseMetaData getDatabaseMetaData()
          Return meta data about the underlying database.
 java.lang.Class<? extends DataObject> getDataObjectClassByName(java.lang.String dataObjectClassName)
          Return the Data Object class for a given Data Object class name.
 ISQLAdapter getSQLAdapter()
          Return the SQLAdapter to allow callers to perform some database agnostic operations with GenericQueries.
 StatisticFormatter getStatisticFormatter()
          Return the StatisticFormatter.
 Table getTable(java.lang.Class<? extends DataObject> dataObjectClass)
          Return the table using the data object class.
 Table getTable(java.lang.String dataObjectClassName)
           
 boolean isConnected()
          Return true if we're connected.
 TableMetaData loadTableMetaData(java.lang.Class<? extends DataObject> dataObjectClass)
           
protected  boolean matchClass(java.lang.String searchClassName, java.lang.String matchClassName)
          Return true if the searchClassName matches the matchClassName.
 void setConnected(boolean connected)
          Set the connected flag
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Database

public Database(DatabaseConfiguration databaseConfiguration,
                boolean validateXML)
         throws RimuDBException
Create a Database.

Throws:
RimuDBException
Method Detail

getConnectionManager

public IConnectionManager getConnectionManager()
                                        throws RimuDBException
Return the connection pool manager

Throws:
RimuDBException

getDatabaseConnection

public java.sql.Connection getDatabaseConnection()
                                          throws RimuDBException,
                                                 java.sql.SQLException
Get a connection.

Throws:
RimuDBException
java.sql.SQLException

createSession

public Session createSession()
                      throws RimuDBException
Get a Session

Returns:
Session
Throws:
RimuDBException

connect

public void connect(java.lang.String user,
                    java.lang.String password)
             throws RimuDBException
Connect to the database.

Parameters:
user - java.lang.String
password - java.lang.String
Throws:
RimuDBException

isConnected

public boolean isConnected()
Return true if we're connected.

Returns:
boolean

setConnected

public void setConnected(boolean connected)
Set the connected flag


disconnect

public void disconnect()
                throws RimuDBException
Disconnect from the database.

Throws:
RimuDBException

getTable

public Table getTable(java.lang.Class<? extends DataObject> dataObjectClass)
               throws RimuDBException
Return the table using the data object class.

Returns:
AbstractTable
Throws:
RimuDBException

getAllTables

public Table[] getAllTables()
                     throws RimuDBException
Return an array of all the AbstractTables that have been discovered with this Database.

Returns:
Table[]
Throws:
RimuDBException

forceTableLoad

public void forceTableLoad()
                    throws java.lang.ClassNotFoundException,
                           RimuDBException
Force all the tables configured in the XML config file to be loaded.

Throws:
java.lang.ClassNotFoundException
RimuDBException
java.lang.Exception

getStatisticFormatter

public StatisticFormatter getStatisticFormatter()
Return the StatisticFormatter.

Returns:
StatisticFormatter

getDatabaseConfiguration

public DatabaseConfiguration getDatabaseConfiguration()
Return the DatabaseConfiguration.

Returns:
DatabaseConfiguration

getDatabaseMetaData

public RimuDBDatabaseMetaData getDatabaseMetaData()
Return meta data about the underlying database.

Returns:
RimuDBDatabaseMetaData

getDataObjectClassByName

public java.lang.Class<? extends DataObject> getDataObjectClassByName(java.lang.String dataObjectClassName)
                                                               throws java.lang.ClassNotFoundException
Return the Data Object class for a given Data Object class name.

Parameters:
dataObjectClassName - String
Returns:
Class
Throws:
java.lang.ClassNotFoundException

matchClass

protected boolean matchClass(java.lang.String searchClassName,
                             java.lang.String matchClassName)
Return true if the searchClassName matches the matchClassName. The classes are assumed to be xxxxDO classes, and the matchClassName may not have a leading package name nor a trailing 'DO'.

Parameters:
searchClassName -
matchClassName -
Returns:
boolean

getTable

public Table getTable(java.lang.String dataObjectClassName)
               throws RimuDBException
Throws:
RimuDBException

loadTableMetaData

public TableMetaData loadTableMetaData(java.lang.Class<? extends DataObject> dataObjectClass)
                                throws RimuDBException
Throws:
RimuDBException

getSQLAdapter

public ISQLAdapter getSQLAdapter()
Return the SQLAdapter to allow callers to perform some database agnostic operations with GenericQueries.

Returns:
ISQLAdapter


Copyright © 2008-2011 Simon Ritchie. All Rights Reserved.