Package org.apache.commons.dbutils

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


    String id = request.getParameter("id");
    String sql = "delete from category where category_id=" + id;
    QueryRunner qr = DbHelper.getQueryRunner();

    try {
      qr.update(sql);
    } catch (SQLException e) {

      e.printStackTrace();
    }
    request.getRequestDispatcher("/servlet/CategoryServlet?method=list")
View Full Code Here


    String level = request.getParameter("level");
    String sql = "update category set category_name=?, category_level=? where category_id=?";
    String params[] = { name, level, id };
    QueryRunner qr = DbHelper.getQueryRunner();
    try {
      qr.update(sql, params);
    } catch (SQLException e) {

      e.printStackTrace();
    }
    request.getRequestDispatcher("/servlet/CategoryServlet?method=list")
View Full Code Here

    @Override
    public int update(String query, Object... params) throws JuDbException {
      try {
        QueryRunner qr = new QueryRunner();
        return qr.update(this.getConnection(), query, this.processParams(params));
      } catch (SQLException ex) {
        throw new JuDbException("Couldn't execute update: " + query, ex);
      }
    }
   
View Full Code Here

        // Use a single connection so that LAST_INSERT_ID works.
        QueryRunner runner = new QueryRunner();
        Connection conn = Application.getDB().getDataSource().getConnection();

        runner.update(conn, "UPDATE report_observation SET errorId = NULL WHERE 1=1");
        runner.update(conn, "DELETE FROM report_error WHERE 1=1");
        Collection<Report> reports = runner.query(conn, "SELECT * FROM report order by time ASC", reportHandler);
        for (Report report : reports) {
            logger.info("Generating errors for report: "+report);
            Collection<ReportError> oldOpenErrors = runner.query(conn, "SELECT * FROM report_error WHERE closedAt IS NULL" , reportErrorHandler);
View Full Code Here

        // Use a single connection so that LAST_INSERT_ID works.
        QueryRunner runner = new QueryRunner();
        Connection conn = Application.getDB().getDataSource().getConnection();

        runner.update(conn, "UPDATE report_observation SET errorId = NULL WHERE 1=1");
        runner.update(conn, "DELETE FROM report_error WHERE 1=1");
        Collection<Report> reports = runner.query(conn, "SELECT * FROM report order by time ASC", reportHandler);
        for (Report report : reports) {
            logger.info("Generating errors for report: "+report);
            Collection<ReportError> oldOpenErrors = runner.query(conn, "SELECT * FROM report_error WHERE closedAt IS NULL" , reportErrorHandler);

View Full Code Here

            for (ReportObservation observation : observations) {
                boolean matched = false;
                for(ReportError error : oldOpenErrors) {
                    if (error.getOid().equals(observation.getOid()) && error.getField().equals(observation.getField())) {
                        // A matched error is still open so remove it from the "old" list
                        runner.update(conn, "UPDATE report_observation SET errorId = ? WHERE id = ?", error.getId(), observation.getId());
                        oldOpenErrors.remove(error);
                        matched = true;
                        break;
                    }
                }
View Full Code Here

                    }
                }

                if (!matched) {
                    // Insert a new open error and map the observation to it
                    runner.update(conn, "INSERT INTO report_error (oid, field, openedAt, closedAt) VALUES (?, ?, ?, NULL)", observation.getOid(), observation.getField(), report.getTime());
                    runner.update(conn, "UPDATE report_observation SET errorId = LAST_INSERT_ID() WHERE id = ?", observation.getId());
                }
            }

            // Close old open errors
View Full Code Here

                }

                if (!matched) {
                    // Insert a new open error and map the observation to it
                    runner.update(conn, "INSERT INTO report_error (oid, field, openedAt, closedAt) VALUES (?, ?, ?, NULL)", observation.getOid(), observation.getField(), report.getTime());
                    runner.update(conn, "UPDATE report_observation SET errorId = LAST_INSERT_ID() WHERE id = ?", observation.getId());
                }
            }

            // Close old open errors
            for (ReportError error : oldOpenErrors) {
View Full Code Here

                }
            }

            // Close old open errors
            for (ReportError error : oldOpenErrors) {
                runner.update(conn, "UPDATE report_error SET closedAt = ? WHERE id = ?", report.getTime(), error.getId());
            }
        }

        conn.close();
    }
View Full Code Here

        logger.info("Reading " + prefix+".page_file.txt");
        loadPageFile(new File(directory, prefix+".page_file.txt"), bills);

        SpotCheckBill testbill = bills.get("S1743A");

        runner.update("insert ignore into report(time) values(?)", date);
        Report report = runner.query("select * from report where time = ?", new BeanHandler<Report>(Report.class), date);
        runner.update("delete from report_observation where reportId = ?", report.getId());

        for(String id : bills.keySet()) {
            //logger.info("checking bill "+id);
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.