use of io.seata.common.exception.DataAccessException in project seata by seata.
the class LogStoreDataBaseDAO method queryBranchTransactionDO.
@Override
public List<BranchTransactionDO> queryBranchTransactionDO(List<String> xids) {
int length = xids.size();
List<BranchTransactionDO> rets = new ArrayList<>(length * 3);
String paramsPlaceHolder = org.apache.commons.lang.StringUtils.repeat("?", ",", length);
String sql = LogStoreSqlsFactory.getLogStoreSqls(dbType).getQueryBranchTransaction(branchTable, paramsPlaceHolder);
Connection conn = null;
PreparedStatement ps = null;
ResultSet rs = null;
try {
conn = logStoreDataSource.getConnection();
conn.setAutoCommit(true);
ps = conn.prepareStatement(sql);
for (int i = 0; i < length; i++) {
ps.setString(i + 1, xids.get(i));
}
rs = ps.executeQuery();
while (rs.next()) {
rets.add(convertBranchTransactionDO(rs));
}
return rets;
} catch (SQLException e) {
throw new DataAccessException(e);
} finally {
IOUtil.close(rs, ps, conn);
}
}
use of io.seata.common.exception.DataAccessException in project seata by seata.
the class LogStoreDataBaseDAO method queryGlobalTransactionDO.
@Override
public GlobalTransactionDO queryGlobalTransactionDO(long transactionId) {
String sql = LogStoreSqlsFactory.getLogStoreSqls(dbType).getQueryGlobalTransactionSQLByTransactionId(globalTable);
Connection conn = null;
PreparedStatement ps = null;
ResultSet rs = null;
try {
conn = logStoreDataSource.getConnection();
conn.setAutoCommit(true);
ps = conn.prepareStatement(sql);
ps.setLong(1, transactionId);
rs = ps.executeQuery();
if (rs.next()) {
return convertGlobalTransactionDO(rs);
} else {
return null;
}
} catch (SQLException e) {
throw new DataAccessException(e);
} finally {
IOUtil.close(rs, ps, conn);
}
}
use of io.seata.common.exception.DataAccessException in project seata by seata.
the class LockStoreDataBaseDAO method isLockable.
@Override
public boolean isLockable(List<LockDO> lockDOs) {
Connection conn = null;
try {
conn = lockStoreDataSource.getConnection();
conn.setAutoCommit(true);
if (!checkLockable(conn, lockDOs)) {
return false;
}
return true;
} catch (SQLException e) {
throw new DataAccessException(e);
} finally {
IOUtil.close(conn);
}
}
use of io.seata.common.exception.DataAccessException in project XHuiCloud by sindaZeng.
the class LogStoreDataBaseDAO method queryGlobalTransactionDO.
@Override
public GlobalTransactionDO queryGlobalTransactionDO(String xid) {
String sql = LogStoreSqlsFactory.getLogStoreSqls(dbType).getQueryGlobalTransactionSQL(globalTable);
Connection conn = null;
PreparedStatement ps = null;
ResultSet rs = null;
try {
conn = logStoreDataSource.getConnection();
conn.setAutoCommit(true);
ps = conn.prepareStatement(sql);
ps.setString(1, xid);
rs = ps.executeQuery();
if (rs.next()) {
return convertGlobalTransactionDO(rs);
} else {
return null;
}
} catch (SQLException e) {
throw new DataAccessException(e);
} finally {
IOUtil.close(rs, ps, conn);
}
}
use of io.seata.common.exception.DataAccessException in project XHuiCloud by sindaZeng.
the class LogStoreDataBaseDAO method queryBranchTransactionDO.
@Override
public List<BranchTransactionDO> queryBranchTransactionDO(List<String> xids) {
int length = xids.size();
List<BranchTransactionDO> rets = new ArrayList<>(length * 3);
String paramsPlaceHolder = org.apache.commons.lang.StringUtils.repeat("?", ",", length);
String sql = LogStoreSqlsFactory.getLogStoreSqls(dbType).getQueryBranchTransaction(branchTable, paramsPlaceHolder);
Connection conn = null;
PreparedStatement ps = null;
ResultSet rs = null;
try {
conn = logStoreDataSource.getConnection();
conn.setAutoCommit(true);
ps = conn.prepareStatement(sql);
for (int i = 0; i < length; i++) {
ps.setString(i + 1, xids.get(i));
}
rs = ps.executeQuery();
while (rs.next()) {
rets.add(convertBranchTransactionDO(rs));
}
return rets;
} catch (SQLException e) {
throw new DataAccessException(e);
} finally {
IOUtil.close(rs, ps, conn);
}
}
Aggregations