Thursday, April 21, 2011

Is MySQL JDBC driver compliant with the JDBC spec?

Hi,

I am using Connector/J 5.1.10 as the JDBC driver for my Database application (which uses MySQL).

I have found that although the default ResultSet returned by a Statement is of type TYPE_FORWARD_ONLY, I am still able to safely call the previous() method on the ResultSet.

I also looked at the source code (com.mysql.jdbc.ResultSetImpl), and found out that it too does not do any checks for the type of the ResultSet.

Is Connector/J not fully compliant with the JDBC spec ?

Thanks.

From stackoverflow
  • According to the release notes the driver is compliant with all of the tests that Sun makes publicly available.

    Some parts of the spec are vague, mysql specifically says so in the release notes. Perhaps the spec doesn't say what the vendor should do if you traverse back on a forward_only cursor ... the vendor has a choice whether to throw an exception at you or not.

    The public tests can't test the parts of the spec where a decision is left to the vendor's discretion.

    divesh premdeep : But the spec definitely mentions what should happen if we attempt to call previous() on a result set that can be scrolled only forwards; the javadoc says that an SQLException should be thrown.
  • The API documentation says that ResultSet#previous() should throw an SQLException "if ... the result set type is TYPE_FORWARD_ONLY", so I guess it's safe to assume that J/Connector violates the specification here.

0 comments:

Post a Comment