I need a quick help on this one, thanks!
I'm trying to check if a member exists in the database with this code:
public boolean memberExists(int id) {
   try {
      open();
      PreparedStatement pstmt = conn.prepareStatement("SELECT * FROM client WHERE id = ?");
      pstmt.setInt(1,id);
      boolean _res = pstmt.executeQuery().getRow() > 0;
      close();
      return _res;
    }
    catch (SQLException e){ System.out.print(e); }
       return false;
    }
}
The method open() gets a new connection and the close() method closes the connection. Pretty straightforward.
The thing that drives me nuts is that it always returns 0 rows. Even the query SELECT * FROM client returns 0 rows.
I used sqlitebrowser.exe to inspect my database and the exact same queries returns the right number of rows.
I think that I already ran into this problem before, but I don't remember what it was exactly. I feel like I'm missing something.
Also, in my code, I can INSERT INTO the database, but not SELECT. This is really strange.
The
open()method.
public DBConnector open() {
    boolean _exists = new File(path).exists();
    try {
        conn = DriverManager.getConnection("jdbc:sqlite:" + path);
        if (!_exists) create();
    } catch (SQLException e) {
        System.out.println(e.getMessage());
    }
    return this;
}
 
    