?? transmanager.java
字號:
package llm.pool.relation;
import java.sql.Connection;
import java.sql.Statement;
import java.sql.SQLException;
/**
* TransManager : 數據庫事務管理
*/
public final class TransManager {
// public static final int ORACLE = 0;
public static final int SYBASE = 1;
public TransManager() {
}
/**
* 事務開始執行
* @param conn Connection
* @param dbType int
* @throws SQLException
*/
public static void beginTrans(Connection conn, int dbType) throws
SQLException {
if (dbType == SYBASE) {
Statement stmt = conn.createStatement();
stmt.execute("begin tran");
stmt.close();
}
else
conn.setAutoCommit(false);
}
/**
* 事務完成后提交
* @param conn Connection
* @param dbType int
* @throws SQLException
*/
public static void commitTrans(Connection conn, int dbType) throws
SQLException {
if (dbType == SYBASE) {
Statement stmt = conn.createStatement();
stmt.execute("commit tran");
stmt.close();
}
else
conn.commit();
}
/**
* 事務失敗后回滾
* @param conn Connection
* @param dbType int
* @throws SQLException
*/
public static void rollbackTrans(Connection conn, int dbType) throws
SQLException {
if (dbType == SYBASE) {
Statement stmt = conn.createStatement();
stmt.execute("rollback tran");
stmt.close();
}
else
conn.rollback();
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -