db2jcc4.jar Invalid parameter: Unknown column name

后端 未结 1 1349
你的背包
你的背包 2020-12-21 02:20

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

相关标签:
1条回答
  • 2020-12-21 02:39

    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 new ResultSetMetaData behavior but you need other features of JDBC 4.0, set the useJDBC4ColumnNameAndLabelSemantics Connection or DataSource property to DB2BaseDataSource.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.

    0 讨论(0)
提交回复
热议问题