title: parameterized insert/update in sql
body: <p>I am trying to insert into a db that I have, and I'd like to do so through parameters. I am connecting to a postgres db using java. </p>
  
  <p>I can connect to the db just fine. I know that because I have various operations that I am using that are already working were I can see, and update existing rows in my db. I am having trouble with INSERT. </p>
  
  <p>I have the following: </p>
  
  <pre><code>private String _update_rentals = "INSERT into rentals (cid, mid) values (?,?)"; 
  private PreparedStatement _update_rentals_statement; 
  
  private String _update_movie_status = "UPDATE Movie SET checkedout = true WHERE mid = ?";
  private PreparedStatement _update_movie_status_statement;
  </code></pre>
  
  <p>And I initialize them: </p>
  
  <pre><code>_update_movie_status_statement = _customer_db.prepareStatement(_update_movie_status); 
          _update_rentals_statement = _customer_db.prepareStatement(_update_rentals); 
  </code></pre>
  
  <p>And</p>
  
  <pre><code>while (movieAvail.next()){
              System.out.println(movieAvail.getBoolean(1));
              if (movieAvail.getBoolean(1) == false){
                  //Do chekcout
  
                  _update_rentals_statement.clearParameters();
                  _update_rentals_statement.setInt(1, cid);
                  _update_rentals_statement.setInt(2, mid);
                  _update_rentals_statement.executeQuery(); 
  
                  _update_movie_status_statement.clearParameters();
                  _update_movie_status_statement.setInt(1, mid);
                  _update_movie_status_statement.executeQuery(); 
  
  
                  System.out.println("Enjoy your movie!"); 
              } 
  }
  </code></pre>
  
  <p>I am getting an error with both of the executeQuery() calls. For some reason I am getting the following error with both: </p>
  
  <pre><code>Exception in thread "main" org.postgresql.util.PSQLException: No results were returned by the query.
  </code></pre>
  
  <p>I looked at other posts, and I believed that I was following syntax for both insert/ update correctly, so maybe I am overlooking some aspect of this. </p>
  
  <p>This is all part of a larger code base, so I did not want to include the methods these pieces of code are in. But these are the isolated instances which play a part with this code. </p>