org.gjt.tw.dbobjects
Class ConnectionBroker

java.lang.Object
  |
  +--org.gjt.tw.dbobjects.ConnectionBroker
All Implemented Interfaces:
IBroker

public class ConnectionBroker
extends java.lang.Object
implements IBroker

Database Connection Broker Implementation for DbConnectionBroker


Constructor Summary
ConnectionBroker(java.util.Properties properties)
          Constructor
 
Method Summary
 boolean destroy(int milliseconds)
          destroy destroys all connections
 boolean freeConnection(java.sql.Connection conn)
          freeConnection returns the connection to the pool
 java.sql.Connection getConnection()
          getConnection
 boolean init(java.util.Properties properties)
          Initializes the database connection broker.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ConnectionBroker

public ConnectionBroker(java.util.Properties properties)
                 throws DatabaseException
Constructor
Parameters:
properties - Description of Parameter
Throws:
DatabaseException - Description of Exception
Method Detail

getConnection

public java.sql.Connection getConnection()
                                  throws DatabaseException
getConnection
Specified by:
getConnection in interface IBroker
Returns:
returns the connection
Throws:
DatabaseException - Description of Exception

destroy

public boolean destroy(int milliseconds)
                throws DatabaseException
destroy destroys all connections
Specified by:
destroy in interface IBroker
Parameters:
milliseconds - Description of Parameter
Returns:
returns true or throws an exception
Throws:
DatabaseException - Description of Exception

freeConnection

public boolean freeConnection(java.sql.Connection conn)
                       throws DatabaseException
freeConnection returns the connection to the pool
Specified by:
freeConnection in interface IBroker
Parameters:
conn - Description of Parameter
Returns:
returns true or throws an exception
Throws:
DatabaseException - Description of Exception

init

public boolean init(java.util.Properties properties)
             throws DatabaseException
Initializes the database connection broker. Has to be done before any data is actually accessed. The property object has to contain at least the following properties (the values in the braces are examples):
  databaseURL : Prefix of database URL ("jdbc:mysql://10.10.10.1:3306/test")
  driverName : Name of jdbc driver ("org.gjt.mm.mysql.Driver")
  username : Name of database user ("root")
  password : Password for database user ("dummy")
  minConnections : Minimum number of open connections to database ("5")
  maxConnections : Maximum number of open connections to database ("10")
  maxConnectionTime : Maximum connection time to the database before reset in days as double ("1.0")
  logFilePath : Name of a file for logging of jdbc activity ("jdbc.log")
 
Parameters:
properties - Description of Parameter
Returns:
boolean True in case of success
Throws:
DatabaseException - Description of Exception