Search in sources :

Example 16 with StoreException

use of io.seata.common.exception.StoreException in project XHuiCloud by sindaZeng.

the class LogStoreDataBaseDAO method updateGlobalTransactionDO.

@Override
public boolean updateGlobalTransactionDO(GlobalTransactionDO globalTransactionDO) {
    String sql = LogStoreSqlsFactory.getLogStoreSqls(dbType).getUpdateGlobalTransactionStatusSQL(globalTable);
    Connection conn = null;
    PreparedStatement ps = null;
    try {
        conn = logStoreDataSource.getConnection();
        conn.setAutoCommit(true);
        ps = conn.prepareStatement(sql);
        ps.setInt(1, globalTransactionDO.getStatus());
        ps.setString(2, globalTransactionDO.getXid());
        return ps.executeUpdate() > 0;
    } catch (SQLException e) {
        throw new StoreException(e);
    } finally {
        IOUtil.close(ps, conn);
    }
}
Also used : StoreException(io.seata.common.exception.StoreException)

Example 17 with StoreException

use of io.seata.common.exception.StoreException in project XHuiCloud by sindaZeng.

the class LogStoreDataBaseDAO method insertBranchTransactionDO.

@Override
public boolean insertBranchTransactionDO(BranchTransactionDO branchTransactionDO) {
    String sql = LogStoreSqlsFactory.getLogStoreSqls(dbType).getInsertBranchTransactionSQL(branchTable);
    Connection conn = null;
    PreparedStatement ps = null;
    try {
        conn = logStoreDataSource.getConnection();
        conn.setAutoCommit(true);
        ps = conn.prepareStatement(sql);
        ps.setString(1, branchTransactionDO.getXid());
        ps.setLong(2, branchTransactionDO.getTransactionId());
        ps.setLong(3, branchTransactionDO.getBranchId());
        ps.setString(4, branchTransactionDO.getResourceGroupId());
        ps.setString(5, branchTransactionDO.getResourceId());
        ps.setString(6, branchTransactionDO.getBranchType());
        ps.setInt(7, branchTransactionDO.getStatus());
        ps.setString(8, branchTransactionDO.getClientId());
        ps.setString(9, branchTransactionDO.getApplicationData());
        return ps.executeUpdate() > 0;
    } catch (SQLException e) {
        throw new StoreException(e);
    } finally {
        IOUtil.close(ps, conn);
    }
}
Also used : StoreException(io.seata.common.exception.StoreException)

Example 18 with StoreException

use of io.seata.common.exception.StoreException in project XHuiCloud by sindaZeng.

the class LogStoreDataBaseDAO method deleteGlobalTransactionDO.

@Override
public boolean deleteGlobalTransactionDO(GlobalTransactionDO globalTransactionDO) {
    String sql = LogStoreSqlsFactory.getLogStoreSqls(dbType).getDeleteGlobalTransactionSQL(globalTable);
    Connection conn = null;
    PreparedStatement ps = null;
    try {
        conn = logStoreDataSource.getConnection();
        conn.setAutoCommit(true);
        ps = conn.prepareStatement(sql);
        ps.setString(1, globalTransactionDO.getXid());
        ps.executeUpdate();
    } catch (SQLException e) {
        throw new StoreException(e);
    } finally {
        IOUtil.close(ps, conn);
    }
    return true;
}
Also used : StoreException(io.seata.common.exception.StoreException)

Example 19 with StoreException

use of io.seata.common.exception.StoreException in project XHuiCloud by sindaZeng.

the class LogStoreDataBaseDAO method deleteBranchTransactionDO.

@Override
public boolean deleteBranchTransactionDO(BranchTransactionDO branchTransactionDO) {
    String sql = LogStoreSqlsFactory.getLogStoreSqls(dbType).getDeleteBranchTransactionByBranchIdSQL(branchTable);
    Connection conn = null;
    PreparedStatement ps = null;
    try {
        conn = logStoreDataSource.getConnection();
        conn.setAutoCommit(true);
        ps = conn.prepareStatement(sql);
        ps.setString(1, branchTransactionDO.getXid());
        ps.setLong(2, branchTransactionDO.getBranchId());
        ps.executeUpdate();
    } catch (SQLException e) {
        throw new StoreException(e);
    } finally {
        IOUtil.close(ps, conn);
    }
    return true;
}
Also used : StoreException(io.seata.common.exception.StoreException)

Example 20 with StoreException

use of io.seata.common.exception.StoreException in project XHuiCloud by sindaZeng.

the class LogStoreDataBaseDAO method updateBranchTransactionDO.

@Override
public boolean updateBranchTransactionDO(BranchTransactionDO branchTransactionDO) {
    String sql = LogStoreSqlsFactory.getLogStoreSqls(dbType).getUpdateBranchTransactionStatusSQL(branchTable);
    Connection conn = null;
    PreparedStatement ps = null;
    try {
        conn = logStoreDataSource.getConnection();
        conn.setAutoCommit(true);
        ps = conn.prepareStatement(sql);
        ps.setInt(1, branchTransactionDO.getStatus());
        ps.setString(2, branchTransactionDO.getXid());
        ps.setLong(3, branchTransactionDO.getBranchId());
        return ps.executeUpdate() > 0;
    } catch (SQLException e) {
        throw new StoreException(e);
    } finally {
        IOUtil.close(ps, conn);
    }
}
Also used : StoreException(io.seata.common.exception.StoreException)

Aggregations

StoreException (io.seata.common.exception.StoreException)39 PreparedStatement (java.sql.PreparedStatement)20 SQLException (java.sql.SQLException)20 Connection (java.sql.Connection)18 TransactionException (io.seata.core.exception.TransactionException)7 RedisException (io.seata.common.exception.RedisException)4 ResultSet (java.sql.ResultSet)4 Jedis (redis.clients.jedis.Jedis)4 StringJoiner (java.util.StringJoiner)3 LockDO (io.seata.core.store.LockDO)2 StoreMode (io.seata.core.store.StoreMode)2 Date (java.util.Date)2 HashMap (java.util.HashMap)2 Transaction (redis.clients.jedis.Transaction)2 BranchRegisterRequest (io.seata.core.protocol.transaction.BranchRegisterRequest)1 BranchRegisterResponse (io.seata.core.protocol.transaction.BranchRegisterResponse)1 BranchReportRequest (io.seata.core.protocol.transaction.BranchReportRequest)1 BranchReportResponse (io.seata.core.protocol.transaction.BranchReportResponse)1 GlobalBeginRequest (io.seata.core.protocol.transaction.GlobalBeginRequest)1 GlobalBeginResponse (io.seata.core.protocol.transaction.GlobalBeginResponse)1