ResultSet not positioned properly, I don't know where exactly to call next()
<p>I've seen a lot questions like this, but none of them has an answer I need. 
I have created a prepared statement which will update my table Tickets. Now to the method buyTickets() I give parameters of CustomerId (knr), PerformanceId(aid) and No. of Ticekts to buy (anzTickets). I have to loop through my Query and for every ticket (number of wanted tickets - anzTickets) I have to call prepared Statement. But I got an error which says that ResultSet is not properly positioned. I'm not really sure where and how to call next() so that preparedStatement can be executed in each row? Here is my code :</p>

<pre><code> public void prepareStatements() throws SQLException {

    try {
        pstmt_updateTicket = connection.prepareStatement("UPDATE Ticket SET kunde = ? WHERE tid = ? AND auffuehrung = ?");

    } catch (SQLException ex) {
        Logger.getLogger(Szenario1.class.getName()).log(Level.SEVERE, null, ex);
    }
}
</code></pre>

<p>This was my prepared statement and here is my buyTickets() method : </p>

<pre><code>public double buyTickets(int knr, int aid, int anzTickets) throws Exception {
    double newgesamtpreis = 0;
    Statement stmt = connection.createStatement();
    PreparedStatement pstmt = pstmt_updateTicket;

    try {
        int anzT = anzTickets;
        int freiTickets = 0;
        ResultSet rs = stmt.executeQuery("SELECT tid, count(tid) FROM Ticket WHERE kunde IS NULL GROUP BY tid;");

        if (anzT &gt; freiTickets) {
            throw new Exception("Es gibt nicht so viele frei Tickets");
        } else {
                for (int i = 0; i &lt; anzT; i++) {
                    pstmt.setInt(1, knr);
                    pstmt.setInt(2, rs.getInt(1));
                    pstmt.setInt(3, aid);
                    pstmt.executeUpdate();
                    rs.next();
                }

            }
            ResultSet rs3 = stmt.executeQuery("SELECT SUM(preis) FROM Ticket WHERE kunde IS NOT NULL");
            newgesamtpreis = rs3.getDouble(1);

    } catch (Exception ex) {
        Logger.getLogger(Szenario1.class.getName()).log(Level.SEVERE, null, ex);
    } finally {
        stmt.close();
        pstmt.close();
    }

    return newgesamtpreis;
}
</code></pre>