[Demonstration 1]

[Buggy Method]
@POST
public Response insertBookedBoth(String postData) throws SQLException, ParseException {
    String q = "INSERT INTO book_booth(persons, date_time, name, phone, email) VALUES((?), (?), (?), (?), (?))";
    try (Connection conn = Database.getConnection();
        PreparedStatement st = conn.prepareStatement(q)) {
        Gson gson = new Gson();
        BookBooth booth = gson.fromJson(postData, BookBooth.class);
        Date dateTime = new SimpleDateFormat("yy-MM-dd hh:mm").parse((booth.book_date.trim() + " " + booth.book_time.trim()));
        st.setInt(1, booth.persons);
        st.setTimestamp(2, new Timestamp(dateTime.getTime()));
        st.setString(3, booth.name);
        st.setString(4, booth.phone);
        st.setString(5, booth.email);
        st.executeUpdate();
        return Response.ok(new UpdateMessage("created", Database.getAutoIncrementID(st)).toJson()).build();
    }
}

[Buggy Hunk]
PreparedStatement st = conn.prepareStatement(q)) {

[Patch]
PreparedStatement st = conn.prepareStatement(q, Statement.RETURN_GENERATED_KEYS)) {

[Demonstration 2]

[Buggy Method]
public void setLength(int min, int max) {
    assert (min <= max);
    setMin(min);
    setMax(max);
    this.length = (int) (Math.random() * (max - min) + min + 1);
}

[Buggy Hunk]
this.length = (int) (Math.random() * (max - min) + min + 1);

[Patch]
this.length = (int) (Math.random() * (max - min + 1) + min);

[Demonstration 3]

[Buggy Method]
public Shop getShopBySellerId(int sellerId) {
    try {
        Connection conn = establishConnection();
        List<String> shopCategories = new ArrayList<>();
        String shopName = "";
        PreparedStatement st = conn.prepareStatement("SELECT * " + "FROM Users " + "WHERE id = ?");
        st.setInt(1, sellerId);
        ResultSet rs = st.executeQuery();
        if (rs.next()) {
            shopName = rs.getString("shopName");
            PreparedStatement shopSt = conn.prepareStatement("SELECT category " + "FROM ShopCategories " + "WHERE sellerId = ?");
            shopSt.setInt(1, sellerId);
            ResultSet shopRS = shopSt.executeQuery();
            while (shopRS.next()) {
                shopCategories.add(rs.getString(1));
            }
        }
        conn.close();
        return new Shop(sellerId, shopName, shopCategories);
    } catch (Exception e) {
        System.out.println(e.getMessage());
    }
    return null;
}

[Buggy Hunk]
shopCategories.add(rs.getString(1));

[Patch]
shopCategories.add(shopRS.getString(1));