Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<blockquote> <p>com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: 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 '? or MemberName = ?' at line 1</p> </blockquote> <p>MySQL doesn't understand the meaning of <code>?</code> in the SQL query. It's indeed invalid SQL syntax. So somehow it's not been replaced by <code>PreparedStatement</code>. And guess what?</p> <pre><code>PreparedStatement s = conn.prepareStatement(query); s.setInt(1, intValue); s.setString(2, strValue); rs = s.executeQuery(query); // Fail! </code></pre> <p>You're overridding the prepared query with the original query! You need to call the argumentless <a href="http://download.oracle.com/javase/6/docs/api/java/sql/PreparedStatement.html#executeQuery%28%29" rel="nofollow"><code>PreparedStatement#executeQuery()</code></a> method instead of <a href="http://download.oracle.com/javase/6/docs/api/java/sql/Statement.html#executeQuery%28java.lang.String%29" rel="nofollow"><code>Statement#executeQuery(String)</code></a>.</p> <pre><code>PreparedStatement s = conn.prepareStatement(query); s.setInt(1, intValue); s.setString(2, strValue); rs = s.executeQuery(); // OK! </code></pre> <hr> <p>Unrelated to the problem, your code is leaking resources. The DB will run out of them after several hours and your application will crash. To fix this, you need to follow the JDBC idiom of closing <code>Connection</code>, <code>Statement</code> and <code>ResultSet</code> in the <code>finally</code> block of the <code>try</code> block where they're been acquired. Check the <a href="http://download.oracle.com/javase/tutorial/jdbc/basics/index.html" rel="nofollow">JDBC basic tutorial</a> for more detail.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload