本文整理汇总了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);
}