tppt.xopen
Class DBManager

java.lang.Object
  |
  +--tppt.xopen.DBManager

public class DBManager
extends java.lang.Object

DBManager is responsbile to interact to the DBMS through the JDBC. It is used by the ResourceManager.

Version:
2.0
Author:
Jodie Wu

Field Summary
private  java.sql.Connection connection
          The database connection.
private  java.lang.String dbname
          The name of DBMS.
private  boolean isChained
           
private  java.sql.Statement stmt
          the Statement object.
 
Constructor Summary
DBManager()
          The empty constructor.
 
Method Summary
 boolean closeTransaction()
          Close the DB Connection.
 boolean commitTransaction()
          Commit the transaction.
 boolean createConnection(DBSetting setting)
          Create the connection to the database according to the JDBC setting passed from user's Application Program.
 boolean executeTransaction(java.lang.String sql)
          Execute the SQL command.
 java.lang.String getDBName()
          Get the name of DBMS the manager connect to.
static void main(java.lang.String[] args)
           
 boolean rollbackTransaction()
          Rollback the transaction.
 void setChained(boolean flag)
           
 boolean startTransaction()
          Start the local transaction.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

connection

private java.sql.Connection connection
The database connection.

stmt

private java.sql.Statement stmt
the Statement object.

isChained

private boolean isChained

dbname

private java.lang.String dbname
The name of DBMS. Currently it supposed "DB2" and "SYBASE".
Constructor Detail

DBManager

public DBManager()
The empty constructor.
Method Detail

createConnection

public boolean createConnection(DBSetting setting)
Create the connection to the database according to the JDBC setting passed from user's Application Program. This method is called by ResourceManager.
Parameters:
setting - the JDBC setting
Returns:
true if connection creates sucessfully, false otherwise.

getDBName

public java.lang.String getDBName()
Get the name of DBMS the manager connect to.
Returns:
"DB2" or "SYBASE"

setChained

public void setChained(boolean flag)

startTransaction

public boolean startTransaction()
Start the local transaction. Notice that DB2 and Sybase are different in initializing the transaction. ex:Sybase has to say "begin transaction" db2 need not.
Returns:
true if transaction starts sucessfully, false otherwise.

commitTransaction

public boolean commitTransaction()
Commit the transaction.
Returns:
true if transaction commits sucessfully, false otherwise.

rollbackTransaction

public boolean rollbackTransaction()
Rollback the transaction.
Returns:
true if rollback sucessfully, false otherwise.

executeTransaction

public boolean executeTransaction(java.lang.String sql)
Execute the SQL command.
Parameters:
sql - the SQL String.
Returns:
true if SQL command executes sucessfully, false otherwise.

closeTransaction

public boolean closeTransaction()
Close the DB Connection.
Returns:
true if connection close properly, false otherwise.

main

public static void main(java.lang.String[] args)