Learnings

Friday, January 30, 2009

java.sql.SQLException: [IBM][JDBC Driver] CLI0626E prepareStatement with auto-generated keys is not supported in this version of DB2 JDBC 2.0 driver.

I faced the above error when I called prepareStatement with just one parameter after the query, not realizing that the version of the API which takes only one parameter after the query maps to auto_generated keys and not to resultset type (which takes a 3 and 4 parameter version).

i.e:
prepareStatement(String sql, int autoGeneratedKeys)
Creates a default PreparedStatement object that has the capability to retrieve auto-generated keys.

is not to be confused with:
prepareStatement(String sql, int resultSetType, int resultSetConcurrency)
Creates a PreparedStatement object that will generate ResultSet objects with the given type and concurrency.

There is NO version which is:
prepareStatement(String sql, int resultSetType)

Labels: