title: How to get query string in catch block of MySQL exception in java?
body: <p>How can I get SQL query that was received <br>by MySQL server when it raises exception?<br>
  <br>
  I have a code similar to the following:</p>
  
  <pre><code>Connection con = null;
  PreparedStatement ps = null;
  try {
      con = DbConnectionManager.getConnection();
      ps = con.prepareStatement(query);
      setStatementParameters(ps, params);
      ps.executeUpdate();
  } catch (SQLExeption e) {
      // How to get wrong query here?
  } finally {
      DbConnectionManager.closeConnection(ps, con);
  }
  </code></pre>
  
  <p>Where query variable is like "INSERT into <code>someTable</code> (<code>qwe</code>, <code>asd</code>) VALUES (?, ?)"<br>
  The question is how can I get query string in the catch block?</p>