|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--tppt.db.DBLocker
DBLocker
is the class that is responsbile to obtain and releasse the
Database lock for the single user mode. By using this class we can ensure
there is only one user accessing the database at a time. Note that different DBMS
has different ways to obtain the lock; it needs different stored procedure that is
defined in the sync.xml file and there is different SQL State code
to catch. Therefore, you should use this class as interface and each DBMS has to
extends this class and implement its own class that overwrite how to get the
db lock and its own SQL state code.
SybaseDBLocker
,
DB2DBLocker
Field Summary | |
protected static java.sql.Connection |
conn
DB Connection |
protected static int |
LOCK_SP_NOT_EXIST
The SQL State Error code: the getDBLock stored procedure does not exist. |
protected static int |
LOCK_TABLE_NOT_EXIST
The SQL State Error code: the Sync table does not exist. |
protected static int |
TABLE_ALREADY_EXIST
The SQL State Error code: the Sync table already exist. |
protected static int |
TABLE_LOCK_INUSE
The SQL State Error code: the Sync table has been locked. |
Constructor Summary | |
DBLocker()
The constructor |
Method Summary | |
static boolean |
closeConnection(java.sql.Connection conn)
Close the connection and it results in db lock releasing |
static boolean |
closeStmt(java.sql.Statement stmt)
Close the statement. |
static boolean |
createConnection()
connect to the database using the id and passd from GlobalData class. |
static boolean |
createSyncTable(java.lang.String tablename,
java.sql.Connection connection)
Create the Sync table if it does not exist. |
static boolean |
getDBLock()
Obtain the database lock. |
static void |
main(java.lang.String[] args)
|
static void |
releaseDBLock()
Release the lock. |
Methods inherited from class java.lang.Object |
|
Field Detail |
protected static final int LOCK_TABLE_NOT_EXIST
protected static final int TABLE_ALREADY_EXIST
protected static final int TABLE_LOCK_INUSE
protected static final int LOCK_SP_NOT_EXIST
protected static java.sql.Connection conn
Constructor Detail |
public DBLocker()
Method Detail |
public static boolean getDBLock()
public static void releaseDBLock()
closeConnection(java.sql.Connection)
public static boolean closeConnection(java.sql.Connection conn)
conn
- The database coneectionpublic static boolean closeStmt(java.sql.Statement stmt)
stmt
- the statemenet objectpublic static boolean createConnection()
public static boolean createSyncTable(java.lang.String tablename, java.sql.Connection connection)
tablename
- the name of table.connection
- DB connection.public static void main(java.lang.String[] args)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |