use of com.sun.messaging.jmq.jmsserver.persist.jdbc.DBManager in project openmq by eclipse-ee4j.
the class JMSBGDAOImpl method getUpdatedTime.
/**
* @param conn database connection
* @param name jmsbridge name
* @param logger_ can be null;
* @throws KeyNotFoundException if not found else Exception on error
*/
@Override
public long getUpdatedTime(Connection conn, String name, java.util.logging.Logger logger_) throws KeyNotFoundException, Exception {
long updatedTime = -1;
Connection myconn = conn;
PreparedStatement pstmt = null;
ResultSet rs = null;
Exception myex = null;
try {
DBManager dbMgr = DBManager.getDBManager();
if (conn == null) {
conn = dbMgr.getConnection(true);
myconn = conn;
}
pstmt = dbMgr.createPreparedStatement(conn, selectUpdatedTimeSQL);
pstmt.setString(1, name);
rs = pstmt.executeQuery();
if (!rs.next()) {
throw new KeyNotFoundException("Name " + name + " not found in store");
}
updatedTime = rs.getLong(1);
} catch (Exception e) {
myex = e;
try {
if ((conn != null) && !conn.getAutoCommit()) {
conn.rollback();
}
} catch (SQLException rbe) {
logger.log(Logger.ERROR, BrokerResources.X_DB_ROLLBACK_FAILED + "[" + selectUpdatedTimeSQL + "]", rbe);
}
throw e;
} finally {
closeSQL(rs, pstmt, myconn, myex, logger_);
}
return updatedTime;
}
use of com.sun.messaging.jmq.jmsserver.persist.jdbc.DBManager in project openmq by eclipse-ee4j.
the class TMLogRecordDAOJMSBG method deleteAll.
/**
* Delete all entries for this broker
*
* @param conn database connection
*/
@Override
public void deleteAll(Connection conn) throws BrokerException {
DBManager dbMgr = DBManager.getDBManager();
String whereClause = new StringBuilder(128).append(BROKER_ID_COLUMN).append(" = '").append(dbMgr.getBrokerID()).append('\'').toString();
deleteAll(conn, whereClause, null, 0);
}
use of com.sun.messaging.jmq.jmsserver.persist.jdbc.DBManager in project openmq by eclipse-ee4j.
the class TMLogRecordDAOJMSBG method getLogRecord.
/**
* @param conn database connection
* @param xid the global xid
* @param name the jmsbridge name
* @param logger_ can be null;
* @return null if not found
*/
@Override
public byte[] getLogRecord(Connection conn, String xid, String name, java.util.logging.Logger logger_) throws Exception {
byte[] logRecord = null;
Connection myconn = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
Exception myex = null;
try {
DBManager dbMgr = DBManager.getDBManager();
if (conn == null) {
conn = dbMgr.getConnection(true);
myconn = conn;
}
pstmt = dbMgr.createPreparedStatement(conn, selectLogRecordSQL);
pstmt.setString(1, xid);
pstmt.setString(2, dbMgr.getBrokerID());
rs = pstmt.executeQuery();
if (!rs.next()) {
return null;
}
logRecord = Util.readBytes(rs, 1);
} catch (Exception e) {
myex = e;
try {
if ((conn != null) && !conn.getAutoCommit()) {
conn.rollback();
}
} catch (SQLException rbe) {
logger.log(Logger.ERROR, BrokerResources.X_DB_ROLLBACK_FAILED + "[" + selectLogRecordSQL + "]", rbe);
}
throw e;
} finally {
closeSQL(rs, pstmt, myconn, myex, logger_);
}
return logRecord;
}
use of com.sun.messaging.jmq.jmsserver.persist.jdbc.DBManager in project openmq by eclipse-ee4j.
the class TMLogRecordDAOJMSBG method getCreatedTime.
/**
* @param conn database connection
* @param xid the global xid
* @param name the jmsbridge name
* @param logger_ can be null;
* @throws KeyNotFoundException if not found else Exception on error
*/
@Override
public long getCreatedTime(Connection conn, String xid, String name, java.util.logging.Logger logger_) throws KeyNotFoundException, Exception {
long createdTime = -1;
Connection myconn = conn;
PreparedStatement pstmt = null;
ResultSet rs = null;
Exception myex = null;
try {
DBManager dbMgr = DBManager.getDBManager();
if (conn == null) {
conn = dbMgr.getConnection(true);
myconn = conn;
}
pstmt = dbMgr.createPreparedStatement(conn, selectCreatedTimeSQL);
pstmt.setString(1, xid);
rs = pstmt.executeQuery();
if (!rs.next()) {
throw new KeyNotFoundException("TM Log record not found in store for xid " + xid);
}
createdTime = rs.getLong(1);
} catch (Exception e) {
myex = e;
try {
if ((conn != null) && !conn.getAutoCommit()) {
conn.rollback();
}
} catch (SQLException rbe) {
logger.log(Logger.ERROR, BrokerResources.X_DB_ROLLBACK_FAILED + "[" + selectCreatedTimeSQL + "]", rbe);
}
throw e;
} finally {
closeSQL(rs, pstmt, myconn, myex, logger_);
}
return createdTime;
}
use of com.sun.messaging.jmq.jmsserver.persist.jdbc.DBManager in project openmq by eclipse-ee4j.
the class TMLogRecordDAOJMSBG method getNamesByBroker.
/**
* @param conn database connection
* @param logger_ can be null;
* @return a list of names in all log records owned by the brokerID
*/
@Override
public List getNamesByBroker(Connection conn, String brokerID, java.util.logging.Logger logger_) throws Exception {
List list = new ArrayList();
Connection myconn = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
Exception myex = null;
try {
DBManager dbMgr = DBManager.getDBManager();
if (conn == null) {
conn = dbMgr.getConnection(true);
myconn = conn;
}
pstmt = dbMgr.createPreparedStatement(conn, selectTMNamesByBrokerSQL);
pstmt.setString(1, brokerID);
rs = pstmt.executeQuery();
while (rs.next()) {
list.add(rs.getString(1));
}
} catch (Exception e) {
myex = e;
try {
if ((conn != null) && !conn.getAutoCommit()) {
conn.rollback();
}
} catch (SQLException rbe) {
logger.log(Logger.ERROR, BrokerResources.X_DB_ROLLBACK_FAILED + "[" + selectTMNamesByBrokerSQL + "]", rbe);
}
throw e;
} finally {
closeSQL(rs, pstmt, myconn, myex, logger_);
}
return list;
}
Aggregations