Behavior of SELECT query using executeUpdate

This behaviour is definetely contradicts Statement.executeUpdate API. What's interesting, java.sql.Driver.jdbcCompliant API says "A driver may only report true here if it passes the JDBC compliance tests". I tested oracle.jdbc.OracleDriver.jdbcCompliant - it returns true. I also tested com.mysql.jdbc.Driver.jdbcCompliant - it returns false. But in the same situation as you describe it throws

Exception in thread "main" java.sql.SQLException: Can not issue SELECT via executeUpdate().

It seems that JDBC drivers are unpredictable.


According to the specifications Statement.executeUpdate() method returns the row count for SQL Data Manipulation Language (DML).

UPD: I attempted to make an assumption about the returned result (which is always <=10). It seems, that the oracle statement's implementation returns here a number of a such called premature batch count (according to the decompiled sources OraclePreparedStatement class). This is somehow linked to the update statements. May be this value equals 10 by default.

UPD-2: According to this: Performance Extensions: The premature batch flush count is summed to the return value of the next executeUpdate() or sendBatch() method.


The query you are using doesn't produce a ResultSet but affects Rows obviously. That's why you don't get an SQLException but a count of the no of rows affected. The mystery is why it doesn't go beyond 10. May it is Oracle JDBC Driver Implementation Specific.

Tags:

Java

Oracle

Jdbc