javatools.db
Class DbDatabase

java.lang.Object
  |
  +--javatools.db.DbDatabase

public class DbDatabase
extends java.lang.Object

A class that represents a particular database. A DbDatabase basically consists of some connection parameters plus we keep track of the open connections. The constructor is not public. Use DbManager.getDatabase().


Field Summary
(package private)  java.util.Map connectionThreadMap
           
(package private)  java.lang.String connectString
           
(package private)  java.lang.String driver
           
(package private)  DbManager manager
           
(package private)  java.lang.String name
           
(package private)  java.lang.String password
           
(package private)  java.util.Map tables
           
(package private)  java.util.Map threadConnectionMap
           
(package private)  java.lang.String userName
           
 
Constructor Summary
(package private) DbDatabase(DbManager manager, java.lang.String name, java.lang.String driver, java.lang.String connectString, java.lang.String userName, java.lang.String password)
           
 
Method Summary
 boolean equals(java.lang.Object o)
           
 DbExpr falseExpr()
          Return an expression representing an SQL false expression.
 DbConnection getExistingThreadConnection()
          Get a DbConnection that will be associated with this Thread, but only if one exists already.
 DbConnection getNewConnection()
          Return a brand new DbConnection.
 java.lang.String getProperty(java.lang.String pname)
          A database can have a set of properties associated with it.
 DbSequence getSequence(java.lang.String name)
           
 DbTable getTable(java.lang.String name)
          Return an object representing a particular table in the database.
 DbConnection getThreadConnection()
          Get a DbConnection that will be associated with this Thread.
 boolean hasThreadConnection()
          Does this thread have a default connection associated with it? (i.e.
(package private)  void notifyClose(DbConnection con)
          Notify the DbDatabase that one of its connections has closed.
 DbSelector selector()
          Create a new DbSelector.
 void setProperty(java.lang.String pname, java.lang.String value)
          Set a property for this database.
 java.lang.String toString()
           
 DbExpr trueExpr()
          Return an expression representing an SQL true expression.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

threadConnectionMap

java.util.Map threadConnectionMap

connectionThreadMap

java.util.Map connectionThreadMap

tables

java.util.Map tables

manager

DbManager manager

name

java.lang.String name

driver

java.lang.String driver

connectString

java.lang.String connectString

userName

java.lang.String userName

password

java.lang.String password
Constructor Detail

DbDatabase

DbDatabase(DbManager manager,
           java.lang.String name,
           java.lang.String driver,
           java.lang.String connectString,
           java.lang.String userName,
           java.lang.String password)
Method Detail

setProperty

public void setProperty(java.lang.String pname,
                        java.lang.String value)
                 throws DbException
Set a property for this database.

Parameters:
pname - The new property value
value - The new property value
Throws:
DbException - Description of Exception

getProperty

public java.lang.String getProperty(java.lang.String pname)
                             throws DbException
A database can have a set of properties associated with it. We use . in a properties file and by default we use "driver", "userId", "password" and "connect".

Parameters:
pname - Description of Parameter
Returns:
The property value
Throws:
DbException - Description of Exception

getTable

public DbTable getTable(java.lang.String name)
                 throws DbException
Return an object representing a particular table in the database.

Parameters:
name - The name of the table.
Returns:
The table value
Throws:
DbException - Description of Exception

getSequence

public DbSequence getSequence(java.lang.String name)

getThreadConnection

public DbConnection getThreadConnection()
                                 throws DbException
Get a DbConnection that will be associated with this Thread.

Returns:
The threadConnection value
Throws:
DbException - Description of Exception

getExistingThreadConnection

public DbConnection getExistingThreadConnection()
                                         throws DbException
Get a DbConnection that will be associated with this Thread, but only if one exists already.

Returns:
The existingThreadConnection value
Throws:
DbException - Description of Exception

getNewConnection

public DbConnection getNewConnection()
                              throws DbException
Return a brand new DbConnection.

Returns:
The newConnection value
Throws:
DbException - Description of Exception

equals

public boolean equals(java.lang.Object o)
Overrides:
equals in class java.lang.Object

selector

public DbSelector selector()
                    throws DbException
Create a new DbSelector.

Returns:
Description of the Returned Value
Throws:
DbException - Description of Exception

hasThreadConnection

public boolean hasThreadConnection()
Does this thread have a default connection associated with it? (i.e. has this Thread called getThreadConnection()).

Returns:
Description of the Returned Value

trueExpr

public DbExpr trueExpr()
Return an expression representing an SQL true expression. We use the expression "0 = 0" for this purpose. This is handy when using complex code to construct a big conditional clause, it can be easier to start with a true expression and "AND" expressions onto the end.

Returns:
Description of the Returned Value

falseExpr

public DbExpr falseExpr()
Return an expression representing an SQL false expression. We use the expression "0 = 1" for this purpose. This is handy when using complex code to construct a big conditional clause, it can be easier to start with a false expression and "OR" expressions onto the end.

Returns:
Description of the Returned Value

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

notifyClose

void notifyClose(DbConnection con)
Notify the DbDatabase that one of its connections has closed.

Parameters:
con - Description of Parameter