title: ResultSet in while loop cannot find column name
body: <p>I am trying to print out a list of data from my user table in DBeaver, but whenever I run the Java program to return a list, I get an error saying &quot;userid&quot; column name not found. Do I need to change something in my while loop? Here is my code:</p>
  <pre><code>@Override
  public List&lt;User&gt; findAll() {
      try(Connection conn = ConnectionUtil.getConnection()) {
      
          String sql = &quot;SELECT * FROM user;&quot;;
          
          Statement statement = conn.createStatement();
          
          ResultSet result = statement.executeQuery(sql);
          
          List&lt;User&gt; list = new ArrayList&lt;&gt;();
          
          while (result.next()) {
              User user = new User();
              user.setUserId(result.getInt(&quot;userid&quot;));
              user.setUsername(result.getString(&quot;username&quot;));
              user.setPassword(result.getString(&quot;password&quot;));
              user.setFirstName(result.getString(&quot;firstname&quot;));
              user.setLastName(result.getString(&quot;lastname&quot;));
              user.setEmail(result.getString(&quot;email&quot;));
              
              list.add(user);
          }
          
          return list;
  </code></pre>
  <p><a href="https://i.stack.imgur.com/Lch0N.png" rel="nofollow noreferrer">Here is my DBeaver table</a></p>