goldengate.common.database
Class DbAdmin

java.lang.Object
  extended by goldengate.common.database.DbAdmin

public class DbAdmin
extends Object

Class for access to Database

Author:
Frederic Bregier

Field Summary
 boolean isConnected
          Is this DB Admin connected
 boolean isMultipleDBAccess
          Is this DB Admin accessed by only one thread at a time (no concurrency and no lock/unlock problem)
 boolean isReadOnly
          Is this DB Admin Read Only
static int nbHttpSession
          Number of HttpSession
static int RETRYNB
           
 DbSession session
          session is the Session object for all type of requests
 DbType typeDriver
          Database type
static long WAITFORNETOP
           
 
Constructor Summary
DbAdmin()
          Empty constructor for no Database support (very thin client)
DbAdmin(Connection conn, boolean isread)
          Use a default server for basic connection.
DbAdmin(DbType driver, String server, String user, String passwd)
          Use a default server for basic connection.
DbAdmin(DbType driver, String server, String user, String passwd, boolean write)
          Use a default server for basic connection.
 
Method Summary
static void addConnection(long id, DbSession session)
          Add a Connection into the list
static void checkAllConnections()
          Check all database connections and try to reopen them if disconnected
 void close()
          Close the underlying session.
static void closeAllConnection()
          Close all database connections
 void commit()
          Commit on connection (since in autocommit, should not be used)
static int getNbConnection()
           
 String getPasswd()
           
 String getServer()
           
 String getUser()
           
static void removeConnection(long id)
          Remove a Connection from the list
 String toString()
           
 void validConnection()
          Validate connection
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

RETRYNB

public static int RETRYNB

WAITFORNETOP

public static long WAITFORNETOP

typeDriver

public DbType typeDriver
Database type


isConnected

public boolean isConnected
Is this DB Admin connected


isReadOnly

public boolean isReadOnly
Is this DB Admin Read Only


isMultipleDBAccess

public boolean isMultipleDBAccess
Is this DB Admin accessed by only one thread at a time (no concurrency and no lock/unlock problem)


session

public DbSession session
session is the Session object for all type of requests


nbHttpSession

public static int nbHttpSession
Number of HttpSession

Constructor Detail

DbAdmin

public DbAdmin(DbType driver,
               String server,
               String user,
               String passwd)
        throws GoldenGateDatabaseNoConnectionException
Use a default server for basic connection. Later on, specific connection to database for the scheme that provides access to the table R66DbIndex for one specific Legacy could be done. A this time, only one driver is possible! If a new driver is needed, then we need to create a new DbSession object. Be aware that DbSession.initialize should be call only once for each driver, whatever the number of DbSession objects that could be created (=> need a hashtable for specific driver when created). Also, don't know if two drivers at the same time (two different DbSession) is allowed by JDBC.

Parameters:
driver -
server -
user -
passwd -
Throws:
GoldenGateDatabaseNoConnectionException

DbAdmin

public DbAdmin(DbType driver,
               String server,
               String user,
               String passwd,
               boolean write)
        throws GoldenGateDatabaseNoConnectionException
Use a default server for basic connection. Later on, specific connection to database for the scheme that provides access to the table R66DbIndex for one specific Legacy could be done. A this time, only one driver is possible! If a new driver is needed, then we need to create a new DbSession object. Be aware that DbSession.initialize should be call only once for each driver, whatever the number of DbSession objects that could be created (=> need a hashtable for specific driver when created). Also, don't know if two drivers at the same time (two different DbSession) is allowed by JDBC.

Parameters:
driver -
server -
user -
passwd -
write -
Throws:
GoldenGateDatabaseSqlException
GoldenGateDatabaseNoConnectionException

DbAdmin

public DbAdmin(Connection conn,
               boolean isread)
        throws GoldenGateDatabaseNoConnectionException
Use a default server for basic connection. Later on, specific connection to database for the scheme that provides access to the table R66DbIndex for one specific Legacy could be done. A this time, only one driver is possible! If a new driver is needed, then we need to create a new DbSession object. Be aware that DbSession.initialize should be call only once for each driver, whatever the number of DbSession objects that could be created (=> need a hashtable for specific driver when created). Also, don't know if two drivers at the same time (two different DbSession) is allowed by JDBC.
This version use given connection. typeDriver must be set before !

Parameters:
conn -
isread -
Throws:
GoldenGateDatabaseNoConnectionException

DbAdmin

public DbAdmin()
Empty constructor for no Database support (very thin client)

Method Detail

validConnection

public void validConnection()
                     throws GoldenGateDatabaseNoConnectionException
Validate connection

Throws:
GoldenGateDatabaseNoConnectionException

close

public void close()
Close the underlying session. Can be call even for connection given from the constructor DbAdmin(Connection, boolean).


commit

public void commit()
            throws GoldenGateDatabaseSqlException,
                   GoldenGateDatabaseNoConnectionException
Commit on connection (since in autocommit, should not be used)

Throws:
GoldenGateDatabaseNoConnectionException
GoldenGateDatabaseSqlException

getServer

public String getServer()
Returns:
the server

getUser

public String getUser()
Returns:
the user

getPasswd

public String getPasswd()
Returns:
the passwd

toString

public String toString()
Overrides:
toString in class Object

addConnection

public static void addConnection(long id,
                                 DbSession session)
Add a Connection into the list

Parameters:
id -
session -

removeConnection

public static void removeConnection(long id)
Remove a Connection from the list

Parameters:
id - Id of the connection

getNbConnection

public static int getNbConnection()
Returns:
the number of connection (so number of network channels)

closeAllConnection

public static void closeAllConnection()
Close all database connections


checkAllConnections

public static void checkAllConnections()
Check all database connections and try to reopen them if disconnected



Copyright © 2009-2012 Frederic Bregier. All Rights Reserved.