本文整理匯總了Java中java.sql.Savepoint類的典型用法代碼示例。如果您正苦於以下問題:Java Savepoint類的具體用法?Java Savepoint怎麽用?Java Savepoint使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
Savepoint類屬於java.sql包,在下文中一共展示了Savepoint類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: setSavepoint
import java.sql.Savepoint; //導入依賴的package包/類
/**
* @see Connection#setSavepoint(String)
*/
public java.sql.Savepoint setSavepoint(String arg0) throws SQLException {
checkClosed();
if (isInGlobalTx()) {
throw SQLError.createSQLException("Can't set autocommit to 'true' on an XAConnection", SQLError.SQL_STATE_INVALID_TRANSACTION_TERMINATION,
MysqlErrorNumbers.ER_XA_RMERR, this.exceptionInterceptor);
}
try {
return this.mc.setSavepoint(arg0);
} catch (SQLException sqlException) {
checkAndFireConnectionError(sqlException);
}
return null; // we don't reach this code, compiler can't tell
}
示例2: put
import java.sql.Savepoint; //導入依賴的package包/類
/**
* Stores the Savepoint in static for username + connectionId
*
* @param savepoint
* the Savepoint to store
*/
public void put(Savepoint savepoint) {
debug("Creating a Savepoint for user: " + connectionKey);
if (savepoint == null) {
throw new IllegalArgumentException("savepoint is null!");
}
Set<Savepoint> savepointSet = savepointMap.get(connectionKey);
if (savepointSet == null) {
savepointSet = new LinkedHashSet<Savepoint>();
}
savepointSet.add(savepoint);
savepointMap.put(connectionKey, savepointSet);
}
示例3: beginTransaction
import java.sql.Savepoint; //導入依賴的package包/類
/**
* Begins a transaction on the current database;
*
* @return
* @throws SQLException
*/
public synchronized Savepoint beginTransaction() throws SQLException {
if (this.transaction_connection != null)
throw new RuntimeException("Another transaction is already running: " + transaction_savepoint);
this.transaction_connection = popConnection();
this.transaction_connection.setAutoCommit(false);
this.transaction_savepoint = this.transaction_connection.setSavepoint();
return this.transaction_savepoint;
}
示例4: testRollback
import java.sql.Savepoint; //導入依賴的package包/類
@Test
public void testRollback() throws Exception
{
thrown.expect(SQLFeatureNotSupportedException.class);
AbstractCloudSpannerConnection testSubject;
Savepoint savepoint = null;
// default test
testSubject = createTestSubject();
testSubject.rollback(savepoint);
}
示例5: commit
import java.sql.Savepoint; //導入依賴的package包/類
/**
* See {@link DatabaseConnection#commit(Savepoint)}
*/
public void commit(Class<?> type, Savepoint savepoint) {
try {
String tableName = getDao(type).getTableName();
getConnectionSource().getReadWriteConnection(tableName).commit(savepoint);
} catch (SQLException e) {
throw new Panic(e);
}
}
示例6: setSavepoint
import java.sql.Savepoint; //導入依賴的package包/類
/**
* @see Connection#setSavepoint()
*/
public java.sql.Savepoint setSavepoint() throws SQLException {
MysqlSavepoint savepoint = new MysqlSavepoint(getExceptionInterceptor());
setSavepoint(savepoint);
return savepoint;
}
示例7: setSavepoint
import java.sql.Savepoint; //導入依賴的package包/類
public Savepoint setSavepoint(String name) throws SQLException
{
try
{
return realConnection.setSavepoint(name);
}
catch(SQLException s)
{
String methodCall = "setSavepoint(" + name + ")";
reportException(methodCall, s, null);
throw s;
}
}
示例8: setSavePoint
import java.sql.Savepoint; //導入依賴的package包/類
/**
* 用於在事務中設置一個保存點,屬於線程安全的
*/
public static void setSavePoint() {
Connection connection = tl_conn.get();
if (connection == null) {
throw new RuntimeException("You do not start a Transaction so you can not set a savepoint!");
}
try {
Stack<Savepoint> stack_sp = tl_sp.get();
Savepoint sp = connection.setSavepoint();
stack_sp.push(sp);
} catch (SQLException e) {
throw new RuntimeException(e);
}
}
示例9: releaseSavepoint
import java.sql.Savepoint; //導入依賴的package包/類
/**
* @see Connection#releaseSavepoint(Savepoint)
*/
public void releaseSavepoint(Savepoint arg0) throws SQLException {
checkClosed();
try {
this.mc.releaseSavepoint(arg0);
} catch (SQLException sqlException) {
checkAndFireConnectionError(sqlException);
}
}
示例10: releaseSavepoint
import java.sql.Savepoint; //導入依賴的package包/類
public void releaseSavepoint(Savepoint savepoint) throws SQLException
{
try
{
realConnection.releaseSavepoint(savepoint);
}
catch(SQLException s)
{
String methodCall = "releaseSavepoint(" + savepoint + ")";
reportException(methodCall, s, null);
throw s;
}
}
示例11: newNodeImplInsert
import java.sql.Savepoint; //導入依賴的package包/類
protected Long newNodeImplInsert(NodeEntity node)
{
Long id = null;
Savepoint savepoint = controlDAO.createSavepoint("newNodeImpl");
try
{
// First try a straight insert and risk the constraint violation if the node exists
id = insertNode(node);
controlDAO.releaseSavepoint(savepoint);
}
catch (Throwable e)
{
controlDAO.rollbackToSavepoint(savepoint);
// This is probably because there is an existing node. We can handle existing deleted nodes.
NodeRef targetNodeRef = node.getNodeRef();
Node dbTargetNode = selectNodeByNodeRef(targetNodeRef);
if (dbTargetNode == null)
{
// There does not appear to be any row that could prevent an insert
throw new AlfrescoRuntimeException("Failed to insert new node: " + node, e);
}
else if (dbTargetNode.getDeleted(qnameDAO))
{
Long dbTargetNodeId = dbTargetNode.getId();
// This is OK. It happens when we create a node that existed in the past.
// Remove the row completely
deleteNodeProperties(dbTargetNodeId, (Set<Long>) null);
deleteNodeById(dbTargetNodeId);
// Now repeat the insert but let any further problems just be thrown out
id = insertNode(node);
}
else
{
// A live node exists.
throw new NodeExistsException(dbTargetNode.getNodePair(), e);
}
}
return id;
}
示例12: rollback
import java.sql.Savepoint; //導入依賴的package包/類
/**
* See {@link DatabaseConnection#rollback(Savepoint)}
*/
public void rollback(Class<?> type, Savepoint savepoint) {
try {
String tableName = getDao(type).getTableName();
getConnectionSource().getReadWriteConnection(tableName).rollback(savepoint);
} catch (SQLException e) {
throw new Panic(e);
}
}
示例13: rollback
import java.sql.Savepoint; //導入依賴的package包/類
/**
* @see Connection#rollback(Savepoint)
*/
public void rollback(Savepoint arg0) throws SQLException {
checkClosed();
if (isInGlobalTx()) {
throw SQLError.createSQLException("Can't call rollback() on an XAConnection associated with a global transaction",
SQLError.SQL_STATE_INVALID_TRANSACTION_TERMINATION, MysqlErrorNumbers.ER_XA_RMERR, this.exceptionInterceptor);
}
try {
this.mc.rollback(arg0);
} catch (SQLException sqlException) {
checkAndFireConnectionError(sqlException);
}
}
示例14: setSavepoint
import java.sql.Savepoint; //導入依賴的package包/類
/**
* @see Connection#setSavepoint(String)
*/
public java.sql.Savepoint setSavepoint(String name) throws SQLException {
synchronized (getConnectionMutex()) {
MysqlSavepoint savepoint = new MysqlSavepoint(name, getExceptionInterceptor());
setSavepoint(savepoint);
return savepoint;
}
}
示例15: rollback
import java.sql.Savepoint; //導入依賴的package包/類
@Override
public void rollback(Savepoint savepoint) throws SQLException
{
inner.rollback(savepoint);
}