Exception {
Connection myconn = null;
PreparedStatement pstmt = null;
Exception myex = null;
try {
DBManager dbMgr = DBManager.getDBManager();
if (conn == null) {
conn = dbMgr.getConnection(false);
myconn = conn;
}
if (conn.getAutoCommit()) {
throw new BrokerException(
"Broker Internal Error: Unexpected auto commit SQL connection for update TM log record: "+xid);
}
byte[] currLogRecord = null;
currLogRecord = getLogRecord(conn, xid, name, logger_);
if (currLogRecord == null) {
if (addIfNotExist) {
insert(conn, xid, logRecord, name, logger_);
return;
}
throw new KeyNotFoundException("TM log record not found for "+xid);
}
byte[] newLogRecord = (byte[])callback.update(currLogRecord);
pstmt = conn.prepareStatement(updateLogRecordSQL);
pstmt.setBytes(1, newLogRecord);
pstmt.setLong(2, System.currentTimeMillis());
pstmt.setString(3, xid);
pstmt.setString(4, dbMgr.getBrokerID());
if (pstmt.executeUpdate() == 0) {
Util.checkBeingTakenOver(conn, dbMgr, logger, logger_);
throw new BrokerException(
br.getKString("TM Log record not found in store for "+xid), Status.NOT_FOUND);