Hi,
通过hibernate如下代码,
String querySQL = "from User o";
Query query = getSession().createQuery(querySQL);
query.setFirstResult(0);
query.setMaxResults(10);
query.list();
在DB2 V9.7数据库上查询正常,返回正确查询结果;
但在DB2 V10.1数据库上查询,报如下错误:
WARN (org.hibernate.util.JDBCExceptionReporter:100) - SQL Error: -4700, SQLState: 56038
ERROR (org.hibernate.util.JDBCExceptionReporter:101) - DB2 SQL Error: SQLCODE=-4700, SQLSTATE=56038, SQLERRMC=null, DRIVER=3.64.106
WARN (org.hibernate.util.JDBCExceptionReporter:100) - SQL Error: -516, SQLState: 26501
ERROR (org.hibernate.util.JDBCExceptionReporter:101) - DB2 SQL Error: SQLCODE=-516, SQLSTATE=26501, SQLERRMC=null, DRIVER=3.64.106
WARN (org.hibernate.util.JDBCExceptionReporter:100) - SQL Error: -514, SQLState: 26501
ERROR (org.hibernate.util.JDBCExceptionReporter:101) - DB2 SQL Error: SQLCODE=-514, SQLSTATE=26501, SQLERRMC=SQL_CURLH200C1, DRIVER=3.64.106
ERROR (com.dao.parameter.impl.ParameterDaoImpl:61) - dao error:
org.hibernate.exception.GenericJDBCException: could not execute query
at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:126)
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:114)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
at org.hibernate.loader.Loader.doList(Loader.java:2235)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2129)
at org.hibernate.loader.Loader.list(Loader.java:2124)
at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:401)
at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:363)
at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:196)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1149)
at org.hibernate.impl.QueryImpl.list(QueryImpl.java:102)
实在不解,不知为何,还请大虾给以帮忙!
PS:Hibernate生成的SQL语句:
select * from ( select rownumber() over() as rownumber_, user.code from User user) as temp_ where rownumber_ <= 10
直接通过客户端在连接v9.7版本数据库上执行正常,返回结果正确;
但在连接v10.1版本数据库上执行错误,错误信息如下:
[错误] 脚本行:1-2 ---------------------------------------
ATTEMPT TO USE NEW FUNCTION BEFORE NEW FUNCTION MODE. SQLCODE=-4700, SQLSTATE=56038, DRIVER=3.53.71
更多例外 ... THE CURSOR SQL_CURLH200C2 IS NOT IN A PREPARED STATE. SQLCODE=-514, SQLSTATE=26501, DRIVER=3.53.71
------解决方案--------------------
这不是说的很清楚吗:ATTEMPT TO USE NEW FUNCTION BEFORE NEW FUNCTION MODE
------解决方案--------------------
驱动程序呢,是从v10.1哪里搞来的吗