/** * @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 }
/** * 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); }
/** * 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; }
@Test public void testRollback() throws Exception { thrown.expect(SQLFeatureNotSupportedException.class); AbstractCloudSpannerConnection testSubject; Savepoint savepoint = null; // default test testSubject = createTestSubject(); testSubject.rollback(savepoint); }
/** * 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); } }
/** * @see Connection#setSavepoint() */ public java.sql.Savepoint setSavepoint() throws SQLException { MysqlSavepoint savepoint = new MysqlSavepoint(getExceptionInterceptor()); setSavepoint(savepoint); return savepoint; }
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; } }
/** * 用于在事务中设置一个保存点,属于线程安全的 */ 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); } }
/** * @see Connection#releaseSavepoint(Savepoint) */ public void releaseSavepoint(Savepoint arg0) throws SQLException { checkClosed(); try { this.mc.releaseSavepoint(arg0); } catch (SQLException sqlException) { checkAndFireConnectionError(sqlException); } }
public void releaseSavepoint(Savepoint savepoint) throws SQLException { try { realConnection.releaseSavepoint(savepoint); } catch(SQLException s) { String methodCall = "releaseSavepoint(" + savepoint + ")"; reportException(methodCall, s, null); throw s; } }
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; }
/** * 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); } }
/** * @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); } }
/** * @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; } }
@Override public void rollback(Savepoint savepoint) throws SQLException { inner.rollback(savepoint); }
public Savepoint setSavepoint() throws SQLException { return getActiveConnection().setSavepoint(); }
public void rollback(Savepoint savepoint) throws SQLException { throw helper.unsupported(); }
@Override public void rollback(Savepoint savepoint) throws SQLException { throw new UnsupportedOperationException("Not supported yet."); }
@Override public void rollback(Savepoint s) throws SQLException { throw new UnsupportedOperationException("Not supported yet."); }
public void rollback(Savepoint savepoint) throws SQLException { getActiveMySQLConnection().rollback(savepoint); }
public void testJDBCAutoSavepoints() throws Exception { String sql; int i; PreparedStatement ps; ResultSet rs; Savepoint sp1; int rowcount = 0; sql = "drop table t if exists"; stmt.executeUpdate(sql); sql = "create table t(id int, fn varchar(40), ln varchar(40), zip int)"; stmt.executeUpdate(sql); //-- setup for following tests conn1.setAutoCommit(false); sql = "insert into t values(?,?,?,?)"; ps = conn1.prepareStatement(sql); ps.setString(2, "Mary"); ps.setString(3, "Peterson-Clancy"); i = 0; for (; i < 10; i++) { ps.setInt(1, i); ps.setInt(4, i); ps.executeUpdate(); } sp1 = conn1.setSavepoint(); for (; i < 12; i++) { ps.setInt(1, i); ps.setInt(4, i); ps.executeUpdate(); } conn1.rollback(sp1); rs = stmt.executeQuery("select count(*) from t"); rs.next(); rowcount = rs.getInt(1); assertEquals(10, rowcount); rs.close(); }
@Override default void releaseSavepoint(Savepoint savepoint) throws SQLException { }
public void releaseSavepoint(Savepoint arg0) throws SQLException { getActiveMySQLConnection().releaseSavepoint(arg0); }
@Override public Savepoint setSavepoint(String name) throws SQLException { return null; }
public Savepoint setSavepoint() throws SQLException { return connection.setSavepoint(); }
/** * <!-- start generic documentation --> * Removes the given <code>Savepoint</code> * object from the current transaction. Any reference to the * savepoint after it have been removed will cause an * <code>SQLException</code> to be thrown. <p> * * <!-- end generic documentation --> * * @param savepoint the <code>Savepoint</code> object to be removed * @exception SQLException if a database access error occurs or * the given <code>Savepoint</code> object is not a valid * savepoint in the current transaction * * @see jdbcSavepoint * @see java.sql.Savepoint * @since JDK 1.4, HSQLDB 1.7.2 */ //#ifdef JAVA4 public synchronized void releaseSavepoint(Savepoint savepoint) throws SQLException { String msg; jdbcSavepoint sp; Result req; checkClosed(); if (savepoint == null) { msg = "savepoint is null"; throw Util.sqlException(Trace.INVALID_JDBC_ARGUMENT, msg); } // fredt - might someone call this with a Savepoint from a different driver??? if (!(savepoint instanceof jdbcSavepoint)) { throw Util.sqlException(Trace.INVALID_JDBC_ARGUMENT); } sp = (jdbcSavepoint) savepoint; if (this != sp.connection) { msg = savepoint.getSavepointName() + " was not issued on this connection"; throw Util.sqlException(Trace.INVALID_JDBC_ARGUMENT, msg); } req = Result.newReleaseSavepointRequest(sp.name); try { Result result = sessionProxy.execute(req); if (result.isError()) { Util.throwError(result); } } catch (HsqlException e) { Util.throwError(e); } }
public void releaseSavepoint(Savepoint savepoint) { }
public void releaseSavepoint(Savepoint savepoint) throws SQLException { validate(); this.getConnection().releaseSavepoint(savepoint); }
@Override public void rollback(Savepoint savepoint) throws SQLException { checkNotClosed(); throw new SQLFeatureNotSupportedException( "Savepoints are not supported. (Drill is not transactional.)" ); }
@Override public void releaseSavepoint(Savepoint savepoint) throws SQLException { lazyEnlistmentCheck(); wrappedConnection.releaseSavepoint( savepoint ); }
/** * @see Connection#rollback(Savepoint) */ public void rollback(final Savepoint savepoint) throws SQLException { synchronized (getConnectionMutex()) { if (versionMeetsMinimum(4, 0, 14) || versionMeetsMinimum(4, 1, 1)) { checkClosed(); try { if (this.connectionLifecycleInterceptors != null) { IterateBlock<Extension> iter = new IterateBlock<Extension>(this.connectionLifecycleInterceptors.iterator()) { @Override void forEach(Extension each) throws SQLException { if (!((ConnectionLifecycleInterceptor) each).rollback(savepoint)) { this.stopIterating = true; } } }; iter.doForAll(); if (!iter.fullIteration()) { return; } } StringBuilder rollbackQuery = new StringBuilder("ROLLBACK TO SAVEPOINT "); rollbackQuery.append('`'); rollbackQuery.append(savepoint.getSavepointName()); rollbackQuery.append('`'); java.sql.Statement stmt = null; try { stmt = getMetadataSafeStatement(); stmt.executeUpdate(rollbackQuery.toString()); } catch (SQLException sqlEx) { int errno = sqlEx.getErrorCode(); if (errno == 1181) { String msg = sqlEx.getMessage(); if (msg != null) { int indexOfError153 = msg.indexOf("153"); if (indexOfError153 != -1) { throw SQLError.createSQLException("Savepoint '" + savepoint.getSavepointName() + "' does not exist", SQLError.SQL_STATE_ILLEGAL_ARGUMENT, errno, getExceptionInterceptor()); } } } // We ignore non-transactional tables if told to do so if (getIgnoreNonTxTables() && (sqlEx.getErrorCode() != SQLError.ER_WARNING_NOT_COMPLETE_ROLLBACK)) { throw sqlEx; } if (SQLError.SQL_STATE_COMMUNICATION_LINK_FAILURE.equals(sqlEx.getSQLState())) { throw SQLError.createSQLException("Communications link failure during rollback(). Transaction resolution unknown.", SQLError.SQL_STATE_TRANSACTION_RESOLUTION_UNKNOWN, getExceptionInterceptor()); } throw sqlEx; } finally { closeStatement(stmt); } } finally { this.needsPing = this.getReconnectAtTxEnd(); } } else { throw SQLError.createSQLFeatureNotSupportedException(); } } }
@Override public Savepoint setSavepoint() throws SQLException { return con.setSavepoint(); }
@Override public void releaseSavepoint(Savepoint savepoint) throws SQLException { con.releaseSavepoint(savepoint); }
@Override public Savepoint setSavepoint() throws SQLException { return conn.setSavepoint(); }
public boolean rollback(Savepoint s) throws SQLException { return true; }