Search in sources :

Example 1 with KeyNotFoundException

use of com.sun.messaging.bridge.api.KeyNotFoundException 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;
}
Also used : DBManager(com.sun.messaging.jmq.jmsserver.persist.jdbc.DBManager) KeyNotFoundException(com.sun.messaging.bridge.api.KeyNotFoundException) StoreBeingTakenOverException(com.sun.messaging.jmq.jmsserver.util.StoreBeingTakenOverException) BrokerException(com.sun.messaging.jmq.jmsserver.util.BrokerException) DupKeyException(com.sun.messaging.bridge.api.DupKeyException) KeyNotFoundException(com.sun.messaging.bridge.api.KeyNotFoundException)

Example 2 with KeyNotFoundException

use of com.sun.messaging.bridge.api.KeyNotFoundException 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;
}
Also used : DBManager(com.sun.messaging.jmq.jmsserver.persist.jdbc.DBManager) DupKeyException(com.sun.messaging.bridge.api.DupKeyException) KeyNotFoundException(com.sun.messaging.bridge.api.KeyNotFoundException) StoreBeingTakenOverException(com.sun.messaging.jmq.jmsserver.util.StoreBeingTakenOverException) BrokerException(com.sun.messaging.jmq.jmsserver.util.BrokerException) KeyNotFoundException(com.sun.messaging.bridge.api.KeyNotFoundException)

Example 3 with KeyNotFoundException

use of com.sun.messaging.bridge.api.KeyNotFoundException in project openmq by eclipse-ee4j.

the class TMLogRecordDAOJMSBG method getUpdatedTime.

/**
 * @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 getUpdatedTime(Connection conn, String xid, 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, xid);
        rs = pstmt.executeQuery();
        if (!rs.next()) {
            throw new KeyNotFoundException("TM Log record not found in store for xid " + xid);
        }
        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;
}
Also used : DBManager(com.sun.messaging.jmq.jmsserver.persist.jdbc.DBManager) DupKeyException(com.sun.messaging.bridge.api.DupKeyException) KeyNotFoundException(com.sun.messaging.bridge.api.KeyNotFoundException) StoreBeingTakenOverException(com.sun.messaging.jmq.jmsserver.util.StoreBeingTakenOverException) BrokerException(com.sun.messaging.jmq.jmsserver.util.BrokerException) KeyNotFoundException(com.sun.messaging.bridge.api.KeyNotFoundException)

Example 4 with KeyNotFoundException

use of com.sun.messaging.bridge.api.KeyNotFoundException in project openmq by eclipse-ee4j.

the class JMSBGDAOImpl method getBrokerId.

/**
 * @param conn database connection
 * @param name jmsbridge name
 * @param logger_ can be null;
 * @throws KeyNotFoundException if not found else Exception on error
 */
@Override
public String getBrokerId(Connection conn, String name, java.util.logging.Logger logger_) throws Exception {
    String brokerId = 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, selectBrokerIdSQL);
        pstmt.setString(1, name);
        rs = pstmt.executeQuery();
        if (!rs.next()) {
            throw new KeyNotFoundException("Name " + name + " not found in store");
        }
        brokerId = 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 + "[" + selectBrokerIdSQL + "]", rbe);
        }
        throw e;
    } finally {
        closeSQL(rs, pstmt, myconn, myex, logger_);
    }
    return brokerId;
}
Also used : DBManager(com.sun.messaging.jmq.jmsserver.persist.jdbc.DBManager) KeyNotFoundException(com.sun.messaging.bridge.api.KeyNotFoundException) StoreBeingTakenOverException(com.sun.messaging.jmq.jmsserver.util.StoreBeingTakenOverException) BrokerException(com.sun.messaging.jmq.jmsserver.util.BrokerException) DupKeyException(com.sun.messaging.bridge.api.DupKeyException) KeyNotFoundException(com.sun.messaging.bridge.api.KeyNotFoundException)

Example 5 with KeyNotFoundException

use of com.sun.messaging.bridge.api.KeyNotFoundException in project openmq by eclipse-ee4j.

the class JMSBGDAOImpl method delete.

/**
 * @param conn database connection
 * @param name to identify the TM
 * @param logger_ can be null;
 * @throws KeyNotFoundException if not found else Exception on error
 */
@Override
public void delete(Connection conn, String name, java.util.logging.Logger logger_) throws Exception {
    Connection myconn = null;
    PreparedStatement pstmt = null;
    Exception myex = null;
    try {
        DBManager dbMgr = DBManager.getDBManager();
        if (conn == null) {
            conn = dbMgr.getConnection(true);
            myconn = conn;
        }
        pstmt = dbMgr.createPreparedStatement(conn, deleteSQL);
        pstmt.setString(1, name);
        pstmt.setString(2, dbMgr.getBrokerID());
        if (pstmt.executeUpdate() == 0) {
            throw new KeyNotFoundException("Name " + name + " not found in store ");
        }
    } catch (Exception e) {
        myex = e;
        try {
            if ((conn != null) && !conn.getAutoCommit()) {
                conn.rollback();
            }
        } catch (SQLException e1) {
            String emsg = BrokerResources.X_DB_ROLLBACK_FAILED;
            logger.log(Logger.ERROR, emsg, e1);
            Util.logExt(logger_, java.util.logging.Level.SEVERE, emsg, e1);
        }
        throw e;
    } finally {
        closeSQL(null, pstmt, myconn, myex, logger_);
    }
}
Also used : DBManager(com.sun.messaging.jmq.jmsserver.persist.jdbc.DBManager) KeyNotFoundException(com.sun.messaging.bridge.api.KeyNotFoundException) StoreBeingTakenOverException(com.sun.messaging.jmq.jmsserver.util.StoreBeingTakenOverException) BrokerException(com.sun.messaging.jmq.jmsserver.util.BrokerException) DupKeyException(com.sun.messaging.bridge.api.DupKeyException) KeyNotFoundException(com.sun.messaging.bridge.api.KeyNotFoundException)

Aggregations

DupKeyException (com.sun.messaging.bridge.api.DupKeyException)9 KeyNotFoundException (com.sun.messaging.bridge.api.KeyNotFoundException)9 DBManager (com.sun.messaging.jmq.jmsserver.persist.jdbc.DBManager)9 BrokerException (com.sun.messaging.jmq.jmsserver.util.BrokerException)9 StoreBeingTakenOverException (com.sun.messaging.jmq.jmsserver.util.StoreBeingTakenOverException)9