I am wondering about what the correct behavior should when you call cancel() on a PreparedStatement that has parameter values set (assuming that the JDBC driver you are using supports it). Should the set values be retained if execute has not been attempted?
I am asking about the correct behavior defined by JDBC, not the behavior of a particular database driver.
For example,
String query = "SELECT * FROM t where t.c1 = ?";
PreparedStatement ps = con.prepareStatement(query);
ps.setInt(1, 1);
ps.cancel();
ps.execute();
Should the parameter value 1 be retained?
What about this? Are both batched parameter values retained?
Reader charReader1 = new InputStream(new FileInputStream("SomeBigFile"));
ps.setCharacterInputStream(1, charReader1, -1);
ps.addBatch();
ps.cancel();
Reader charReader2 = new InputStream(new FileInputStream("AnotherBigFile"));
ps.setCharacterInputStream(1, charReader2, -1);
ps.addBatch();
ps.executeBatch();