java db2jcc4.jar 无效参数:未知列名
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15981711/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
db2jcc4.jar Invalid parameter: Unknown column name
提问by Entropy
I previously asked the following question: DB2 query Unknown column name ERRORCODE=-4460, SQLSTATE=null
我之前问过以下问题: DB2 query Unknown column name ERRORCODE=-4460, SQLSTATE=null
We have since learned that changing from db2jcc4.jar (JCC) from db2jcc.jar (UNIVERSAL) solves the issue in our development environment. The problem is that the one tha tdoesn't work is the newer one. We don't want to step backwards on our driver without really good cause. But the reason why the query in the above link is invalid in the new driver is not understood by me.
从那以后,我们了解到将 db2jcc4.jar (JCC) 更改为 db2jcc.jar (UNIVERSAL) 可以解决我们开发环境中的问题。问题是那个不起作用的那个是新的。我们不想在没有真正正当理由的情况下让我们的司机退步。但是上面链接中的查询在新驱动中无效的原因我不明白。
We know it is that column...if we take it out of the results by forcing an empty space, everything works (except we don't get the data). The query works fine in other environments.
我们知道它是那一列……如果我们通过强制留空将其从结果中取出,则一切正常(除非我们没有获得数据)。该查询在其他环境中工作正常。
I have seen some posts implying that this error is related to the result set meta data getColumn() method being inconsistent between JDBC3 and JDBC4. But we're not doing anything special in this query that isn't being done in many other queries, at least not as far as we can tell.
我看到一些帖子暗示此错误与 JDBC3 和 JDBC4 之间的结果集元数据 getColumn() 方法不一致有关。但是我们在这个查询中没有做任何在许多其他查询中没有做的特殊事情,至少我们可以说没有。
Does anyone know what about this query might be setting things off? Is there a fix for this behavior...either some setting or workaround, or a new driver?
有谁知道这个查询可能会引起什么问题?是否有针对此行为的修复方法...某些设置或解决方法,或新驱动程序?
The full exception:
完整的例外:
com.ibm.db2.jcc.a.SqlException: [jcc][10150][10300][4.3.111] Invalid parameter: Unknown >column name FILTER_VALUE_DECODE. ERRORCODE=-4460, SQLSTATE=null at com.ibm.db2.jcc.a.dd.a(dd.java:660) at com.ibm.db2.jcc.a.dd.a(dd.java:60) at com.ibm.db2.jcc.a.dd.a(dd.java:103) at com.ibm.db2.jcc.a.ib.a(ib.java:1674) at com.ibm.db2.jcc.a.yl.a(yl.java:1625) at com.ibm.db2.jcc.a.yl.getString(yl.java:1468) at com.ibm.ws.rsadapter.jdbc.WSJdbcResultSet.getString(WSJdbcResultSet.java:2467) at org.hibernate.type.StringType.get(StringType.java:41) at org.hibernate.type.NullableType.nullSafeGet(NullableType.java:184) at org.hibernate.type.NullableType.nullSafeGet(NullableType.java:210) at org.hibernate.loader.custom.CustomLoader$ScalarResultColumnProcessor.extract(CustomLoader.java:501) at org.hibernate.loader.custom.CustomLoader$ResultRowProcessor.buildResultRow(CustomLoader.java:447) at org.hibernate.loader.custom.CustomLoader.getResultColumnOrRow(CustomLoader.java:344) at org.hibernate.loader.Loader.getRowFromResultSet(Loader.java:647) at org.hibernate.loader.Loader.doQuery(Loader.java:745) at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:270) at org.hibernate.loader.Loader.doList(Loader.java:2294) ... 64 more
com.ibm.db2.jcc.a.SqlException:[jcc][10150][10300][4.3.111] 无效参数:未知 > 列名 FILTER_VALUE_DECODE。ERRORCODE=-4460,SQLSTATE=null 在 com.ibm.db2.jcc.a.dd.a(dd.java:660) 在 com.ibm.db2.jcc.a.dd.a(dd.java:60)在 com.ibm.db2.jcc.a.dd.a(dd.java:103) 在 com.ibm.db2.jcc.a.ib.a(ib.java:1674) 在 com.ibm.db2.jcc .a.yl.a(yl.java:1625) 在 com.ibm.db2.jcc.a.yl.getString(yl.java:1468) 在 com.ibm.ws.rsadapter.jdbc.WSJdbcResultSet.getString(WSJdbcResultSet .java:2467) 在 org.hibernate.type.StringType.get(StringType.java:41) 在 org.hibernate.type.NullableType.nullSafeGet(NullableType.java:184) 在 org.hibernate.type.NullableType.nullSafeGet( NullableType.java:210) 在 org.hibernate.loader.custom.CustomLoader$ScalarResultColumnProcessor.extract(CustomLoader.java:501) 在 org.hibernate.loader。
回答by Mark Rotteveel
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).
您可能正在使用 Hibernate 3.x。Hibernate 3.x 尝试通过列的值columnName
(即列ResultSetMetaData
的原始名称的属性)检索列的值,而 JDBC 要求(根据规范)通过columnLabel
(AS
别名的属性,或者如果不是)检索它们的值t 指定了原始列名)。
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.
旧版本的 JDBC 并不完全清楚columnName
和之间的区别columnLabel
,因此实现驱动程序要么为两个属性返回相同的值,要么期望columnName
检索值。
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
):
IBM 更改了此行为以符合 DB2 9.5 驱动程序中的 JDBC 规范,请参阅此文档。要恢复到旧行为,您需要将连接属性指定useJDBC4ColumnNameAndLabelSemantics
为DB2BaseDataSource.NO
(其值为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.
解决方法
如果您无法更改应用程序以符合新ResultSetMetaData
行为,但需要 JDBC 4.0 的其他功能,请将useJDBC4ColumnNameAndLabelSemantics
Connection 或 DataSource 属性设置为DB2BaseDataSource.NO
(2) 以保持旧行为。
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.
另一种选择是升级到更新版本的 Hibernate (4.x),因为这(至少在默认情况下)使用columnLabel
来检索值。