 <p>It seems that my question was nonsence. Here's my code:</p> <pre><code>PreparedStatement stmt = con.prepareStatement(query); stmt.setLong(1, key); stmt.execute(query); </code></pre> <p><code>query</code> is (obiously) String. What fixed the problem is removing <code>query</code> from <code>stmt.execute(query)</code></p> <p>I'm still not sure if the behavior of <code>execute()</code> in such a case is correct.</p>