title: JDBC Error when trying a parametric update
body: <p>I'm trying to update the record in my MySql database using JDBC.
  Here is the method:</p>
  <pre><code>public void updateGareCorse(CorrePer c) {
          Connection con = null;
          PreparedStatement ps = null;
          ResultSet rs = null;
          try {
              con = DBConnectionPool.getConnection();
              
              String sql = &quot;update corre_per set gare_corse = ?\n&quot;
                      + &quot;   where codice_pilota = ? and anno = ?&quot;;
              ps = con.prepareStatement(sql);
              ps.setString(1, c.getGare_corse());
              ps.setString(2, c.getCodice());
              ps.setInt(3, c.getAnno());
              
              System.out.println(&quot;QUERY:\nUPDATE corre_per SET gare_corse = &quot; + c.getGare_corse()+&quot; WHERE anno = &quot;+ c.getAnno() +&quot; AND codice_pilota = &quot; + c.getCodice()+&quot;)&quot;);
  
              int result = ps.executeUpdate(sql);
  
              if (result &gt; 0) {
                  System.out.println(&quot;Update OK&quot;);
  
              } else {
                  System.out.println(&quot;Update NOT OK&quot;);
              }
              con.commit();
          } catch (SQLException s) {
              System.err.println(s.getMessage());
              Utility.printSQLException(s);
          } finally {
              try {
                  if (rs != null)
                      rs.close();
                  if (ps != null)
                      ps.close();
                  DBConnectionPool.releaseConnection(con);
              } catch (SQLException s) {
                  System.err.println(s.getMessage());
                  Utility.printSQLException(s);
              }
          }
      }
  </code></pre>
  <p>CorrePer is a Java class that represents my CorrePer table and has variables that represent my CorrePer attributes and their getter and setter method.
  Now, when I execute this method, Eclipse gives this error:</p>
  <pre><code>You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '? where codice_pilota = ? and anno = ?' at line 1
  </code></pre>
  <p>Why the method doesn't work? Any help is much appreciated.</p>
  <p>UPDATE: I tried to pass only one parameter at a time, with the others not being parametric, but already written in the query, like this:</p>
  <pre><code>String sql = &quot;update corre_per set gare_corse = \&quot;1-\&quot;\n&quot;
                      + &quot;   where codice_pilota = \&quot;TSU\&quot; and anno = ?&quot;;
              ps = con.prepareStatement(sql);
              //ps.setString(1, c.getGare_corse());
              //ps.setString(1, c.getCodice());
              ps.setInt(1, c.getAnno());
  </code></pre>
  <p>Now it gives error only on the '?' at the end:</p>
  <pre><code>You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '?' at line 2
  </code></pre>
  <p>So looks like there is a problem with the parameters association, but I'm not able to figure out it.</p>