My app uses MySQL on one platform and SQLite on another, as such there are differences, such as that when using query like DELETE FROM USERS
:
- On MySQL,
PreparedStatement.getResultSet()
will returnnull
. - On SQLite,
PreparedStatement.getResultSet()
will throwjava.sql.SQLException: no ResultSet available
.
This may or may not be a bug in SQLite implementation (I think it is supposed to return null
), but I have to deal with this somehow.
I could use a try { ... } catch (SQLException e) { ... }
and if the exception message is "no ResultSet available"
, simply return null manually. This doesn't feel like a right way to do it though.
I could put up an if that makes a check on what JDBC driver is being used and react accordingly, but again, that doesn't feel like a good solution to the problem.
What I would really like is either a method like .hasResultSet()
that returns a boolean
OR a way to get the SQL command (SELECT, UPDATE, INSERT
etc) from a statement that has been executed. I can find neither of the two in SQL API though.