Package org.openqreg.exception

Examples of org.openqreg.exception.DbHandlerException


        dataSourceFound = true;
      } catch (NamingException ne) {
        logger.log(Level.ERROR, "Unable to look up name: " + lookupName, 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;
        } catch (NamingException ne) {
          logger.log(Level.ERROR, "Unable to look up name: " + lookupName, ne);
          throw new DbHandlerException("Can't find " + lookupName
              + " in the JNDI-tree\n" + ne.getMessage());
        }
      }
      con = ds.getConnection();
View Full Code Here


   * @return ResultSet :containing the result of the db query
   * @throws DbHandlerException
   */
  public ResultSet executeQuery(String sqlQuery) throws DbHandlerException {
    if (this.transactionInProgress) {
      throw new DbHandlerException("Cannot execute, a transaction is "
          + "in progress");
    }
    try {
      if (con == null || con.isClosed()) {
        con = ds.getConnection();
      }

      if (logger.isDebugEnabled()) {
        logger.log(Level.DEBUG, "executeQuery: " + sqlQuery);
      }

      stmt = con.createStatement();
      rs = stmt.executeQuery(sqlQuery);

    } catch (SQLException sqle) {
      throw new DbHandlerException(
          "DbHandler - executeQuery: Error getting connection\n"
              + sqle.getMessage(), sqle.getSQLState(), sqle.getErrorCode(),
          sqlQuery);
    }
    return rs;
View Full Code Here

   * @throws DbHandlerException
   */
  public PreparedStatement prepareStatement(String sqlQuery)
      throws DbHandlerException {
    if (this.transactionInProgress) {
      throw new DbHandlerException("prepareStatement: Cannot execute, "
          + "a transaction is in progress");
    }
    try {
      if (this.con == null || con.isClosed()) {
        con = ds.getConnection();
      }
      if (logger.isDebugEnabled()) {
        logger.log(Level.DEBUG, "prepareStatement: " + sqlQuery);
      }
      this.pstmt = con.prepareStatement(sqlQuery);
    } catch (SQLException sqle) {
      throw new DbHandlerException(
          "prepareStatement: Error getting connection\n" + sqle.getMessage(),
          sqle.getSQLState(), sqle.getErrorCode(), sqlQuery);
    }

    return this.pstmt;
View Full Code Here

   * @throws DbHandlerException
   */
  public CallableStatement prepareCall(String sqlQuery)
      throws DbHandlerException {
    if (transactionInProgress) {
      throw new DbHandlerException("Cannot execute, a transaction is "
          + "in progress");
    }
    try {
      if (con == null || con.isClosed()) {
        con = ds.getConnection();
      }
      if (logger.isDebugEnabled()) {
        logger.log(Level.DEBUG, "prepareCall: " + sqlQuery);
      }
      this.cstmt = con.prepareCall(sqlQuery);
    } catch (SQLException sqle) {
      throw new DbHandlerException("Error getting connection\n"
          + sqle.getMessage(), sqle.getSQLState(), sqle.getErrorCode(),
          sqlQuery);
    }

    return cstmt;
View Full Code Here

  public boolean execute() throws DbHandlerException {
    boolean tmp = false;
    try {
      tmp = cstmt.execute();
    } catch (SQLException sqle) {
      throw new DbHandlerException("Error getting connection\n"
          + sqle.getMessage(), sqle.getSQLState(), sqle.getErrorCode());
    }
    return tmp;
  }
View Full Code Here

  public void setString(int parameterIndex, String x) throws DbHandlerException {

    try {
      cstmt.setString(parameterIndex, x);
    } catch (SQLException sqle) {
      throw new DbHandlerException("Unable to set String in statement"
          + sqle.getMessage(), sqle.getSQLState(), sqle.getErrorCode());
    }
  }
View Full Code Here

   */
  public void setInt(int parameterIndex, int x) throws DbHandlerException {
    try {
      cstmt.setInt(parameterIndex, x);
    } catch (SQLException sqle) {
      throw new DbHandlerException("Unable to set int in statement"
          + sqle.getMessage(), sqle.getSQLState(), sqle.getErrorCode());
    }
  }
View Full Code Here

  public void registerOutParameter(int parameterIndex, int sqlType)
      throws DbHandlerException {
    try {
      cstmt.registerOutParameter(parameterIndex, sqlType);
    } catch (SQLException sqle) {
      throw new DbHandlerException("Unable to registering out parameter"
          + sqle.getMessage(), sqle.getSQLState(), sqle.getErrorCode());
    }
  }
View Full Code Here

    String tmp = "";
    try {
      tmp = cstmt.getString(parameterIndex);

    } catch (SQLException sqle) {
      throw new DbHandlerException("Unable to get String from statement"
          + sqle.getMessage(), sqle.getSQLState(), sqle.getErrorCode());
    }
    return tmp;
  }
View Full Code Here

  public int getInt(int parameterIndex) throws DbHandlerException {
    int tmp = -1;
    try {
      tmp = cstmt.getInt(parameterIndex);
    } catch (SQLException sqle) {
      throw new DbHandlerException("Unable to get int from statement"
          + sqle.getMessage(), sqle.getSQLState(), sqle.getErrorCode());
    }
    return tmp;
  }
View Full Code Here

TOP

Related Classes of org.openqreg.exception.DbHandlerException

Copyright © 2018 www.massapicom. 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.