[Demonstration 1]

[Buggy Method]
private static void initV() {
    Statement stmt;
    ResultSet urs, krs, prs;
    String user, keyword, loc;
    double pvalue;
    int index = 0;
    try {
        stmt = conn.createStatement();
        //init V1, userLocMap, u2i
        String sql = "select distinct u_id, location from pdven where day = '" + day + "';";
        urs = stmt.executeQuery(sql);
        V1.clear();
        u2i.clear();
        userLocMap.clear();
        while (urs.next()) {
            user = urs.getString("u_id");
            loc = urs.getString("location");
            V1.add(user);
            // revert user to index in the array[][] "pdv"
            u2i.put(user, index++);
            userLocMap.put(user, loc);
        }
        // init V2, k2i
        sql = "select distinct keyword from pdven where day = '" + day + "';";
        index = 0;
        krs = stmt.executeQuery(sql);
        V2.clear();
        k2i.clear();
        while (krs.next()) {
            keyword = krs.getString("keyword");
            V2.add(keyword);
            // revert keyword to index in the array[][] "pdv"
            k2i.put(keyword, index++);
        }
        // init the array[][] "pdv", pdv[keyword][user]=the pvalue of the pair{"keyword", "user"} of this day
        pdv = new double[V2.size()][V1.size()];
        for (int i = 0; i < V2.size(); i++) for (int j = 0; j < V1.size(); j++) pdv[i][j] = 1;
        sql = "select u_id, keyword, pvalue from pdven where day = '" + day + "';";
        prs = stmt.executeQuery(sql);
        while (prs.next()) {
            user = prs.getString("u_id");
            keyword = prs.getString("keyword");
            pvalue = prs.getDouble("pvalue");
            pdv[k2i.get(keyword)][u2i.get(user)] = pvalue;
        }
        sql = "select province from true_value where date = '" + day + "';";
        prs = stmt.executeQuery(sql);
        String prov;
        while (prs.next()) {
            prov = prs.getString("province");
            //System.out.println(">>> "+prov);
            true_label.add(prov);
        }
    } catch (SQLException e) {
        e.printStackTrace();
    }
}

[Buggy Hunk]
stmt = conn.createStatement();

[Patch]
stmt = RG_TestForPrediction.conn.createStatement();

[Demonstration 2]

[Buggy Method]
public Schedule getSchedule() {
    Connection conn = getConnection();
    Statement stmt = null;
    ResultSet rs = null;
    String query = "SELECT * FROM scheduler.events";
    ArrayList<ScheduledEvent> schedule = new ArrayList<>();
    try {
        stmt = conn.createStatement();
        rs = stmt.executeQuery(query);
        while (rs.next()) {
            schedule.add(new ScheduledEvent(rs.getInt("deviceID"), rs.getString("deviceName"), rs.getString("startDateTime").substring(0, 16), rs.getString("endDateTime").substring(0, 16), rs.getString("newDeviceStatus")));
        }
    } catch (NullPointerException | SQLException ex) {
        ex.printStackTrace();
    } finally {
        closeConnectionWithResultSet(conn, stmt, rs);
    }
    return new Schedule(schedule);
}

[Buggy Hunk]
rs.getString("endDateTime").substring(0,16),

[Patch]
rs.getString("endDateTime"),

[Demonstration 3]

[Buggy Method]
public Map<String, ?> getParams() {
    return params;
}

[Buggy Hunk]
public Map<String, ?> getParams() {

[Patch]
public Map<String, Object> getParams() {