title: java.sql.SQLException: no such column
body: <p>I've been given an assignment to demonstrate CRUD operations using sqlite. When I try to retrieve an item from the database my ResultSet doesn't seem the have the "id" column. I am quite stumped.</p>
  
  <p>This is my ContactRepository class.</p>
  
  <pre><code>public class ContactRepositoryJDBC implements ContactRepository {
  
      private static Connector connector = new Connector();
  
      ...
  
      public Contact getById(int id) throws SQLException {
          Contact contact = null;
  
          try (Connection conn = connector.getConnection();
              PreparedStatement statement = conn
                      .prepareStatement(SQL.GET_CONTACT_BY_ID)) {
              statement.setInt(1, id);
              try (ResultSet resultSet = statement.executeQuery()) {
                  if (resultSet.next()) {
                      contact = new Contact();
                      contact.setId(resultSet.getInt("id"));
                      contact.setFirstName(resultSet.getString("first_name"));
                      contact.setSurname(resultSet.getString("surname"));
                      contact.setHomeNumber(resultSet.getString("home_number"));
                      contact.setCellNumber(resultSet.getString("cell_number"));
                      contact.setEmail(resultSet.getString("email"));
                  }
              }
          }
  
          if (contact == null) {
              System.out.print("no contact with id " + id + " found : ");
          }
          return contact;
      }
  
  ...
  
  }
  </code></pre>
  
  <p>I use a seperate class for my sql statements</p>
  
  <pre><code>public class SQL {
  
  ...
  
  public static final String GET_CONTACT_BY_ID = "SELECT first_name, surname, home_number, cell_number, email FROM Contact WHERE id = ?";
  
  ...
  
  }
  </code></pre>
  
  <p>I get an SQLException "no such column id"</p>
  
  <pre><code>Exception in thread "main" java.sql.SQLException: no such column: 'id'
  at org.sqlite.RS.findColumn(RS.java:121)
  at org.sqlite.RS.getInt(RS.java:293)
  at net.phonebook.repository.ContactRepositoryJDBC.getById(ContactRepositoryJDBC.java:59)
  at net.phonebook.model.app.App.main(App.java:31)    
  </code></pre>
  
  <p>EDIT:</p>
  
  <p>Contact model class</p>
  
  <pre><code>public class Contact {
  
      private int id;
      private String firstName;
      private String surname;
      private String homeNumber;
      private String cellNumber;
      private String email;
  
      public Contact(String firstName, String surname, String homeNumber,
              String cellNumber, String email) {
          this.firstName = firstName;
          this.surname = surname;
          this.homeNumber = homeNumber;
          this.cellNumber = cellNumber;
          this.email = email;
      }
  
      public Contact() {
  
      }
  
      public int getId() {
          return id;
      }
  
      public void setId(int id) {
          this.id = id;
      }
  
      ... getters and setter for everything else
  }
  </code></pre>