Java 类java.sql.Savepoint 实例源码

项目:BibliotecaPS    文件:ConnectionWrapper.java   
/**
 * @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
}
项目:the-vigilantes    文件:ConnectionWrapper.java   
/**
 * @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
}
项目:aceql-http    文件:ConnectionStore.java   
/**
 * 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);
}
项目:jetfuel    文件:Database.java   
/**
 * 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;
}
项目:spanner-jdbc    文件:AbstractCloudSpannerConnectionTest.java   
@Test
public void testRollback() throws Exception
{
    thrown.expect(SQLFeatureNotSupportedException.class);
    AbstractCloudSpannerConnection testSubject;
    Savepoint savepoint = null;

    // default test
    testSubject = createTestSubject();
    testSubject.rollback(savepoint);
}
项目:homunculus    文件:ORMLiteEntityManager.java   
/**
 * 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);
    }
}
项目:lams    文件:ConnectionImpl.java   
/**
 * @see Connection#setSavepoint()
 */
public java.sql.Savepoint setSavepoint() throws SQLException {
    MysqlSavepoint savepoint = new MysqlSavepoint(getExceptionInterceptor());

    setSavepoint(savepoint);

    return savepoint;
}
项目:dswork.jdbc    文件:ConnectionSpy.java   
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;
    }
}
项目:UtilsMaven    文件:JDBCUtils.java   
/**
 * 用于在事务中设置一个保存点,属于线程安全的
 */
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);
    }
}
项目:ProyectoPacientes    文件:ConnectionWrapper.java   
/**
 * @see Connection#releaseSavepoint(Savepoint)
 */
public void releaseSavepoint(Savepoint arg0) throws SQLException {
    checkClosed();

    try {
        this.mc.releaseSavepoint(arg0);
    } catch (SQLException sqlException) {
        checkAndFireConnectionError(sqlException);
    }
}
项目:dswork.jdbc    文件:ConnectionSpy.java   
public void releaseSavepoint(Savepoint savepoint) throws SQLException
{
    try
    {
        realConnection.releaseSavepoint(savepoint);
    }
    catch(SQLException s)
    {
        String methodCall = "releaseSavepoint(" + savepoint + ")";
        reportException(methodCall, s, null);
        throw s;
    }
}
项目:alfresco-repository    文件:AbstractNodeDAOImpl.java   
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;
}
项目:BibliotecaPS    文件:ConnectionWrapper.java   
/**
 * @see Connection#releaseSavepoint(Savepoint)
 */
public void releaseSavepoint(Savepoint arg0) throws SQLException {
    checkClosed();

    try {
        this.mc.releaseSavepoint(arg0);
    } catch (SQLException sqlException) {
        checkAndFireConnectionError(sqlException);
    }
}
项目:homunculus    文件:ORMLiteEntityManager.java   
/**
 * 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);
    }
}
项目:ProyectoPacientes    文件:ConnectionWrapper.java   
/**
 * @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);
    }
}
项目:the-vigilantes    文件:ConnectionImpl.java   
/**
 * @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;
    }
}
项目:Equella    文件:MigrationConnection.java   
@Override
public void rollback(Savepoint savepoint) throws SQLException
{
    inner.rollback(savepoint);
}
项目:ProyectoPacientes    文件:FabricMySQLConnectionProxy.java   
public Savepoint setSavepoint() throws SQLException {
    return getActiveConnection().setSavepoint();
}
项目:calcite-avatica    文件:AvaticaConnection.java   
public void rollback(Savepoint savepoint) throws SQLException {
  throw helper.unsupported();
}
项目:openjdk-jdk10    文件:StubConnection.java   
@Override
public void rollback(Savepoint savepoint) throws SQLException {
    throw new UnsupportedOperationException("Not supported yet.");
}
项目:openjdk-jdk10    文件:StubFilteredRowSetImpl.java   
@Override
public void rollback(Savepoint s) throws SQLException {
    throw new UnsupportedOperationException("Not supported yet.");
}
项目:lams    文件:MultiHostMySQLConnection.java   
public void rollback(Savepoint savepoint) throws SQLException {
    getActiveMySQLConnection().rollback(savepoint);
}
项目:OpenDiabetes    文件:TestJDBCSavepoints.java   
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();
    }
项目:agroal    文件:MockConnection.java   
@Override
default void releaseSavepoint(Savepoint savepoint) throws SQLException {
}
项目:BibliotecaPS    文件:MultiHostMySQLConnection.java   
public void releaseSavepoint(Savepoint arg0) throws SQLException {
    getActiveMySQLConnection().releaseSavepoint(arg0);
}
项目:Agent-Benchmarks    文件:SimulateConnection.java   
@Override public Savepoint setSavepoint(String name) throws SQLException {
    return null;
}
项目:org.ops4j.pax.transx    文件:ConnectionWrapper.java   
public Savepoint setSavepoint() throws SQLException {
    return connection.setSavepoint();
}
项目:parabuild-ci    文件:jdbcConnection.java   
/**
     * <!-- 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);
        }
    }
项目:jdk8u-jdk    文件:StubJdbcRowSetImpl.java   
@Override
public void rollback(Savepoint s) throws SQLException {
    throw new UnsupportedOperationException("Not supported yet.");
}
项目:ProyectoPacientes    文件:FabricMySQLConnectionProxy.java   
public void releaseSavepoint(Savepoint savepoint) {
}
项目:Agent-Benchmarks    文件:SimulateConnection.java   
@Override public Savepoint setSavepoint(String name) throws SQLException {
    return null;
}
项目:sstore-soft    文件:BaseConnectionWrapper.java   
public void releaseSavepoint(Savepoint savepoint) throws SQLException {
    validate();
    this.getConnection().releaseSavepoint(savepoint);
}
项目:QDrill    文件:DrillConnectionImpl.java   
@Override
  public void rollback(Savepoint savepoint) throws SQLException {
  checkNotClosed();
  throw new SQLFeatureNotSupportedException(
      "Savepoints are not supported.  (Drill is not transactional.)" );
}
项目:agroal    文件:ConnectionWrapper.java   
@Override
public void releaseSavepoint(Savepoint savepoint) throws SQLException {
    lazyEnlistmentCheck();
    wrappedConnection.releaseSavepoint( savepoint );
}
项目:ProyectoPacientes    文件:ConnectionImpl.java   
/**
 * @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();
        }
    }
}
项目:burstcoin    文件:FilteredConnection.java   
@Override
public Savepoint setSavepoint() throws SQLException {
    return con.setSavepoint();
}
项目:lams    文件:FabricMySQLConnectionProxy.java   
public Savepoint setSavepoint() throws SQLException {
    return getActiveConnection().setSavepoint();
}
项目:burstcoin    文件:FilteredConnection.java   
@Override
public void releaseSavepoint(Savepoint savepoint) throws SQLException {
    con.releaseSavepoint(savepoint);
}
项目:preflex    文件:ConnectionWrapper.java   
@Override
public Savepoint setSavepoint() throws SQLException {
    return conn.setSavepoint();
}
项目:BibliotecaPS    文件:TestLifecycleInterceptor.java   
public boolean rollback(Savepoint s) throws SQLException {
    return true;
}