title: Why is "while (rs.next())" necessary here?
body: <p>I want to select the maximum line number from my database "<em>Logs</em>" and store it in a variable <code>m</code>.</p>
  
  <p>Here's my code:</p>
  
  <pre><code>ResultSet rs = stmt.executeQuery("Select max(Line) as L from logs");
  
  while (rs.next()) {          // Why do I need this
      int m = rs.getInt("L");
      System.out.println(m);
  }
  </code></pre>
  
  <p>But it doesn't work unless I use <code>while(rs.next())</code>.</p>
  
  <hr>
  
  <p>If I understand correctly, <code>rs.next(</code>) moves the cursor to the next row, but  here, in this result, I only have <strong>one row</strong>.</p>
  
  <p>So, can someone explain why the loop is necessary? The only thing I can think of is that the first cursor is set on the column name, am I right?</p>