No exceptions on violating queries via JDBC
The problem arises when I issue some violating query (e.g. FK constraint) with JDBC statements. Here’s an exmample: Connection con = dataSource.getConnection(); con.setAutoCommit(false); PreparedStatement stmnt = con.prepareStatement("/*Query with wrong FK*/"); stmnt.executeUpdate(); stmnt.close(); // exception is generated internally, but swallowed con.commit(); //no effect con.close(); As can be seen from the log messages, exception is not propagated outside of the driver library. Moreover, next calls to methods like commit have no effect at all. So, you cannot know if the statement executed successfully. Other drivers (like MySQL) throw exception on Statement.executeStatement() call even if autocommit is disabled. Due to this fact tools like Hibernate cannot work correctly. Can anyone comment on this?
0
Comments