Package org.apache.commons.dbutils

Examples of org.apache.commons.dbutils.QueryRunner.query()


      sql += "  (invoice_id = ?)";
      sql += " )";
       
      while (iterator.hasNext()) {
        invoiceMap = (Map) iterator.next();
        paymentMap = (Map) queryRunner.query(sql, invoiceMap.get("invoice_id"), mapRsh);
        balanceDue = invoiceMap.get("amount") == null ? new BigDecimal((double) 0) : (BigDecimal) invoiceMap.get("amount");
        paymentAmount = paymentMap.get("sum_amount") == null ? new BigDecimal((double) 0) : (BigDecimal) paymentMap.get("sum_amount");
        balanceDue = balanceDue.add(paymentAmount.negate());

        invoiceMap.put("amount_paid", paymentAmount);
View Full Code Here


      sql += " where (";
      sql += " (person_role.role_id=role.role_id)";
      sql += " and (person_id = ?)";
      sql += " ) ORDER BY role";

      return (List) queryRunner.query(sql, new Integer(personID), rsh);
    } catch (SQLException se) {
      String message = "SpecificController: SQL Exception: " + se.getMessage();
      log.warning(message);
      throw new ControllerException(se);
    }
View Full Code Here

    ResultSetHandler rshList = new MapListHandler();

    try {
      String sql =
        "select * from person" + " where (" + " (user_name=?)" + " )";
      personMap = (Map) queryRunner.query(sql, userName, rshMap);

      if (personMap == null) {
        // Check if this is the first user: admin
        sql = "select * from person";
        //params[1] = PasswordService.encrypt(passWordInPlainText);
View Full Code Here

      if (personMap == null) {
        // Check if this is the first user: admin
        sql = "select * from person";
        //params[1] = PasswordService.encrypt(passWordInPlainText);
        personMap = (Map) queryRunner.query(sql, rshMap);
       
        // Person could not be found, but there are already persons present
        if (personMap != null) {
          throw new FinderException();
        }
View Full Code Here

      sql =
        "select role_id from person_role where person_id = "
          + personMap.get("person_id");
      List personRoleList =
        (List) queryRunner.query(sql, rshList);
      Iterator iterator = personRoleList.iterator();
      Map personRoleMap = null;
      Map roleMap = null;
      Integer roleID = null;
      ArrayList roleList = new ArrayList(personRoleList.size());
View Full Code Here

        personRoleMap = (Map) iterator.next();
        roleID = (Integer) personRoleMap.get("role_id");
        sql =
          "select role_code from role where role_id = "
            + roleID.intValue();
        roleMap = (Map) queryRunner.query(sql, rshMap);
        roleList.add(roleMap.get("role_code"));
      }

      personMap.put("role_list", roleList);
View Full Code Here

    Map clientMap = null;
    Object obj = null;
   
    try {
      sql = "delete from Client where (ClientID=40)";
      obj = runner.query(conn, sql, null, rsh);
    } catch (SQLException se) {
      System.out.println(se.getMessage());
      return;
    }
   
View Full Code Here

      return;
    }
   
    try {
      sql = "select * from Client where (ClientID=40)";
      clientMap = (Map) runner.query(conn, sql, null, rsh);
      DbUtils.close(conn);
    } catch (SQLException se) {
      System.out.println(se.getMessage());
      return;
    }
View Full Code Here

  public static JSONArray getList(String sql, Object... params) {
    Connection con=DBPool.getConnection();
    final JSONArray jsonArr = new JSONArray();
    try {
      QueryRunner runner = new QueryRunner();
      runner.query(con,sql.toString(), new ResultSetHandler<Object>() {
        public Object handle(ResultSet rs) throws SQLException {
          ResultSetMetaData metaData = rs.getMetaData();
          int cols = metaData.getColumnCount();
          while (rs.next()) {
            JSONObject jsonObj = new JSONObject();
View Full Code Here

      final QueryRunner runner = new QueryRunner();
      final ArrayList<String> stores = new ArrayList<String>();

      Hermes.ui.getDefaultMessageSink().add("Getting message stores....");

      runner.query(connection, statements.getStoresStatement(), new ResultSetHandler()
      {
         public Object handle(ResultSet rs) throws SQLException
         {
            while (rs.next())
            {
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.