NutzCN Logo
精华 db2下使用Daos.queryCount查询sql结果条数错误的问题
发布于 3163天前 作者 qqfe28902f 4473 次浏览 复制 上一个帖子 下一个帖子
标签:

Exception in thread "main" org.nutz.dao.DaoException: !Nutz SQL Error: 'select count(1) from (select * from hospital where hospitalname='四川大学华西医院') as nutz_tmp_1461553010779'
PreparedStatement:
'select count(1) from (select * from hospital where hospitalname='四川大学华西医院') as nutz_tmp_1461553010779'
CaseMessage=DB2 SQL Error: SQLCODE=-20521, SQLSTATE=428HV, SQLERRMC=
;7, DRIVER=3.63.75
at org.nutz.dao.impl.sql.run.NutDaoExecutor.exec(NutDaoExecutor.java:96)
at org.nutz.dao.impl.DaoSupport$DaoExec.invoke(DaoSupport.java:316)
at org.nutz.dao.impl.sql.run.NutDaoRunner.run(NutDaoRunner.java:59)
at org.nutz.dao.impl.DaoSupport.run(DaoSupport.java:239)
at org.nutz.dao.impl.DaoSupport._exec(DaoSupport.java:271)
at org.nutz.dao.impl.DaoSupport.execute(DaoSupport.java:235)
at org.nutz.dao.impl.NutDao.execute(NutDao.java:983)
at org.nutz.dao.util.Daos.queryCount(Daos.java:360)
at com.gd.cmp.test.DataBaseTest.main(DataBaseTest.java:18)
Caused by: com.ibm.db2.jcc.am.SqlSyntaxErrorException: DB2 SQL Error: SQLCODE=-20521, SQLSTATE=428HV, SQLERRMC=
;7, DRIVER=3.63.75
at com.ibm.db2.jcc.am.fd.a(fd.java:679)
at com.ibm.db2.jcc.am.fd.a(fd.java:60)
at com.ibm.db2.jcc.am.fd.a(fd.java:127)
at com.ibm.db2.jcc.am.yn.c(yn.java:2644)
at com.ibm.db2.jcc.am.yn.d(yn.java:2632)
at com.ibm.db2.jcc.am.yn.a(yn.java:2097)
at com.ibm.db2.jcc.t4.cb.h(cb.java:141)
at com.ibm.db2.jcc.t4.cb.b(cb.java:41)
at com.ibm.db2.jcc.t4.q.a(q.java:32)
at com.ibm.db2.jcc.t4.sb.i(sb.java:135)
at com.ibm.db2.jcc.am.yn.gb(yn.java:2066)
at com.ibm.db2.jcc.am.yn.a(yn.java:3120)
at com.ibm.db2.jcc.am.yn.a(yn.java:681)
at com.ibm.db2.jcc.am.yn.executeQuery(yn.java:665)
at org.apache.commons.dbcp.DelegatingStatement.executeQuery(DelegatingStatement.java:208)
at org.apache.commons.dbcp.DelegatingStatement.executeQuery(DelegatingStatement.java:208)
at org.nutz.dao.impl.sql.run.NutDaoExecutor._runSelect(NutDaoExecutor.java:199)
at org.nutz.dao.impl.sql.run.NutDaoExecutor.exec(NutDaoExecutor.java:45)
... 8 more

4 回复

db2不支持as关键字?

select count(1) from (select * from hospital where hospitalname='四川大学华西医院') as nutz_tmp_1461555177968
生成的sql看好像不是 是生成的 as 后面生成了以
开头的问题 去掉执行就对了

@wendal(wendal)
回复用错了。兽总

'select count(1) from (select * from hospital where hospitalname='四川大学华西医院') as _nutz_tmp_1461555177968

@qq_fe28902f 哦,db2不能以下划线开头的意思?看来是bug,我看看怎么改一下

添加回复
请先登陆
回到顶部