I previously asked the following question: DB2 query Unknown column name ERRORCODE=-4460, SQLSTATE=null
We have since learned that changing from db2jcc4.jar (JCC) fr
You are probably using Hibernate 3.x. Hibernate 3.x tries to retrieve values of columns by their columnName
(that is the ResultSetMetaData
property for the original name of the column), while JDBC requires (by specification) that they are retrieved by columnLabel
(the property for the AS
alias, or if that isn't specified the original columnname).
Older versions of JDBC weren't entirely clear about the distinction between columnName
and columnLabel
, so implementing Drivers either returned the same value for both properties, or expected the columnName
to retrieve values.
IBM changed this behavior to conform to the JDBC specification in the DB2 9.5 driver, see this document. To revert to the old behavior, you need to specify the connection property useJDBC4ColumnNameAndLabelSemantics
to DB2BaseDataSource.NO
(which has the value 2
):
Resolution
If you cannot change your applications to conform to the newResultSetMetaData
behavior but you need other features of JDBC 4.0, set theuseJDBC4ColumnNameAndLabelSemantics
Connection or DataSource property toDB2BaseDataSource.NO
(2) to keep the old behavior.
The other option is to upgrade to a newer version of Hibernate (4.x) as this (at least by default) uses the columnLabel
for retrieving values.