Examples of DbHandlerException


Examples of org.openqreg.exception.DbHandlerException

       */
      con.setAutoCommit(false);
      stmt = con.createStatement();
      transactionInProgress = true;
    } catch (SQLException sqle) {
      throw new DbHandlerException(
          "beginTransaction: Error getting connection " + sqle.getMessage(),
          sqle.getSQLState(), sqle.getErrorCode());
    }
  }
View Full Code Here

Examples of org.openqreg.exception.DbHandlerException

   * @throws DbHandlerException
   */
  public int executeUpdate(String sqlQuery) throws DbHandlerException {
    int result = 0;
    if (this.transactionInProgress)
      throw new DbHandlerException("Cannot execute"
          + ", transaction in progress\n");
    try {

      if (con == null || con.isClosed()) {
        con = ds.getConnection();
        stmt = con.createStatement();
      }

      result = stmt.executeUpdate(sqlQuery);
      count += result;

    } catch (SQLException sqle) {
      throw new DbHandlerException(
          "Cannot executeUpdate\n" + sqle.getMessage(), sqle.getSQLState(),
          sqle.getErrorCode());
    } finally {
      try {
        close();
View Full Code Here

Examples of org.openqreg.exception.DbHandlerException

   * @return an int containing rowcount.
   * @throws DbHandlerException
   */
  public int addUpdateToTransaction(String sqlQuery) throws DbHandlerException {
    if (!transactionInProgress)
      throw new DbHandlerException("Transaction " + "not initiated properly\n");
    try {
      if (logger.isDebugEnabled()) {
        logger.log(Level.DEBUG, "addUpdateToTransaction: " + sqlQuery);
      }
      int result = stmt.executeUpdate(sqlQuery);
      count += result;
      return result;
    } catch (SQLException sqle) {
      throw new DbHandlerException("Cannot add update to transaction\n"
          + sqle.getMessage(), sqle.getSQLState(), sqle.getErrorCode(),
          sqlQuery);
    }
  }
View Full Code Here

Examples of org.openqreg.exception.DbHandlerException

   * @throws DbHandlerException
   */
  public ResultSet addQueryToTransaction(String sqlQuery)
      throws DbHandlerException {
    if (!transactionInProgress)
      throw new DbHandlerException("Transaction " + "not initiated properly\n");
    rs = null;
    try {
      if (logger.isDebugEnabled()) {
        logger.log(Level.DEBUG, "addQueryToTransaction: " + sqlQuery);
      }
      rs = stmt.executeQuery(sqlQuery);
    } catch (SQLException sqle) {
      throw new DbHandlerException("Cannot add query to transaction\n"
          + sqle.getMessage(), sqle.getSQLState(), sqle.getErrorCode(),
          sqlQuery);
    }
    return rs;
  }
View Full Code Here

Examples of org.openqreg.exception.DbHandlerException

   *
   * @throws DbHandlerException
   */
  public void commitTransaction() throws DbHandlerException {
    if (!transactionInProgress)
      throw new DbHandlerException("Cannot "
          + "commit. Probable cause: Transaction not properly initiated");
    try {
      con.commit();
      con.setAutoCommit(true);
    } catch (SQLException sqle) {
      throw new DbHandlerException("Cannot commit transaction\n"
          + sqle.getMessage(), sqle.getSQLState(), sqle.getErrorCode());
    } finally {
      transactionInProgress = false;
      try {
        close();
View Full Code Here

Examples of org.openqreg.exception.DbHandlerException

   *
   * @exception DbHandlerException
   */
  public void abortTransaction() throws DbHandlerException {
    if (!transactionInProgress)
      throw new DbHandlerException("Cannot abort."
          + "Probable cause: Transaction not properly initiated");
    try {
      con.rollback();
      if (logger.isInfoEnabled()) {
        logger.log(Level.INFO, "Transaction rolled back");
      }
      con.setAutoCommit(true);
      transactionInProgress = false;
    } catch (SQLException sqle) {
      if (logger.isDebugEnabled()) {
        logger.log(Level.DEBUG, "DbHandler:abortTransaction", sqle);
      }
      throw new DbHandlerException("Cannot abort transaction\n"
          + sqle.getMessage(), sqle.getSQLState(), sqle.getErrorCode());
    } finally {
      try {
        close();
      } catch (DbHandlerException e) {
View Full Code Here

Examples of org.openqreg.exception.DbHandlerException

      }
    } catch (SQLException sqle) {
      if (logger.isDebugEnabled()) {
        logger.log(Level.DEBUG, "DbHandler:close", sqle);
      }
      throw new DbHandlerException("Can't close the resultset\n"
          + sqle.getMessage(), sqle.getSQLState(), sqle.getErrorCode());
    }

    try {
      // Close the statement
      if (stmt != null) {
        stmt.close();
        stmt = null;
      }
    } catch (SQLException sqle) {
      throw new DbHandlerException("Can't close the statement\n"
          + sqle.getMessage(), sqle.getSQLState(), sqle.getErrorCode());
    }
    try {
      // Close the statement
      if (pstmt != null) {
        pstmt.close();
        pstmt = null;
      }
    } catch (SQLException sqle) {
      throw new DbHandlerException("Can't close the prepared statement\n"
          + sqle.getMessage(), sqle.getSQLState(), sqle.getErrorCode());
    }
    try {
      // Close the conection. The connection isn't really closed, it's
      // only
      // given back to the connection pool and marked as available.
      if (con != null) {
        con.close();
        con = null;
      }
      initiated = false;
    } catch (SQLException sqle) {
      throw new DbHandlerException("Can't close the connection\n"
          + sqle.getMessage(), sqle.getSQLState(), sqle.getErrorCode());
    }
  }
View Full Code Here

Examples of org.openqreg.exception.DbHandlerException

      initiated = true;
      dataSourceFound = true;
    } catch (NamingException ne) {
      // we can get here if it is the wrong type of server....
      throw new DbHandlerException("Can't find " + lookupName
          + " in the JNDI-tree\n" + ne.getMessage());
    }

    if (!dataSourceFound) {
      try {
        // for tomcat 5 server...
        // if jrun server connection doesn't work this one is used
        // instead

        Context ctx = new InitialContext();
        ds = (DataSource) ctx.lookup("java:comp/env/" + lookupName);

        dataSourceFound = true;
        initiated = true;
      } catch (NamingException ne) {
        throw new DbHandlerException("Can't find " + lookupName
            + " in the JNDI-tree\n" + ne.getMessage());
      }
    }
  }
View Full Code Here

Examples of org.openqreg.exception.DbHandlerException

   * @throws DbHandlerException
   */
  public PreparedStatement addNewPreparedStatementTransaction(String sqlQuery)
      throws SQLException, DbHandlerException {
    if (!transactionInProgress) {
      throw new DbHandlerException("Transaction " + "not initiated properly\n");
    }
    if (logger.isDebugEnabled()) {
      logger
          .log(Level.DEBUG, "addNewPreparedStatementTransaction: " + sqlQuery);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.