I have a code that worked like a charm for many years. It broke with a recent java update on my Mac.
- when using java 6 (1.6.0_65-b14-462-11M4609), it works as expected
- when using java 7 (1.7.0_60-b19), it does not work.
Here's the test code:
PreparedStatement p = mConnection.prepareStatement("SELECT rowid, * FROM cases_customers WHERE case_id = ?");
p.setLong(1, 2);
ResultSet r = p.executeQuery();
System.out.println("One result? " + r.next());
p = mConnection.prepareStatement("SELECT rowid, * FROM cases_customers WHERE case_id = ? + '0'");
p.setLong(1, 2);
r = p.executeQuery();
System.out.println("At least one result? " + r.next());
Conclusion:
At least one result? false
At least one result? true
The second query forces the data to bind as a number due to the addition. Thus, even if the data is bound for so long in the code, it is somehow translated as a string later.
I have not changed my SQLite JDBC driver (which is xerial 3.7.2).
Java Web Start, / jar "" make GNU, javac . jar/app , true/true.
:

DB.java( sqlite-jdbc-3.7.2), DB#sqlbind:
else if (v instanceof Long) {
return bind_long(stmt, pos, ((Long) v).longValue());
}
- java 6,
DB NativeDB.java native bind_long. - java 7,
DB NestedDB.java :
.
@Override
synchronized int bind_long(long stmt, int pos, long v) throws SQLException {
return bind_text(stmt, pos, Long.toString(v));
}
long String.