title: Check if value exists in MySQL DB in Java?
body: <p>I'm creating a game right now that stores quest values into a DB when a player completes his or her quest. The issue I'm having right now is writing a method that searches the MySQL table for the player id and the quest id to check if he or she has <strong>already</strong> completed it.</p>
  
  <p>I'm new to database programming in Java, so this was as far as I got by looking at some sample code elsewhere.</p>
  
  <pre><code>public boolean checkQuest(int questid) {
     Connection con = DatabaseConnection.getConnection();
     PreparedStatement ps = con.prepareStatement("SELECT questid FROM completedQuests WHERE characterid = ?");
     ps.setInt(1, scriptId);
     ResultSet rs = ps.executeQuery();
  </code></pre>
  
  <p>}</p>
  
  <p>Basically, I want to check if the quest id exists in the table. If it doesn't, that means the player has yet to complete the quest and thus it is available.</p>