请问:数据库抛出异常问题是与数据库性能配置有关还是程序问题?

wgcniler 2006-04-28 04:17:01
我用hibernate来实现为持久化。可是在开发过程中,遇到了一个问题。在执行一个查询语句时出现了问题:有时候能正常通过。我认为既然有时候程序能执行说明程序应该是没有问题的,是不是数据库没有作配置好呢?还是其他方面的原因。请高手指点一下我该如何解决这个问题。非常感谢!
hql语句为:
select ob.countyAreaCode,count(*)
from EncourageSupportObject as ob,ESFlowInfo as fi
where ob.countyAreaCode =:areaID
and fi.encourageSupportObject.id=ob.id
and fi.startReasonCode=:startReasonCode
and fi.nowStatusCode in (:saved_noSubmittedCode,:submitted_noConfirmedCode,:confirmedCode)
and fi.opTime>=:yearStartDate and fi.opTime<:endDate
and ob.birthYearMonth>=:birthYearMonthBegin
and ob.birthYearMonth<=:birthYearMonthEnd
group by ob.townAreaCode

抛出的异常为:
javax.servlet.ServletException: Hibernate operation: could not execute query; uncategorized SQLException for
SQL [select encourages0_.resideAreaCode as col_0_0_, count(*) as col_1_0_
from table_EncourageSupportObject encourages0_, table_ESFlowInfo esflowinfo1_
where encourages0_.townAreaCode=?
and esflowinfo1_.encourageSupportObject=encourages0_.id
and esflowinfo1_.startReasonCode=?
and (esflowinfo1_.nowStatusCode in (? , ? , ?))
and esflowinfo1_.opTime>=?
and esflowinfo1_.opTime<?
and encourages0_.birthYearMonth>=?
and encourages0_.birthYearMonth<=?
group by encourages0_.resideAreaCode];
SQL state [24501]; error code [-501]; [IBM][CLI Driver][DB2/NT] SQL0501N 在 FETCH 或 CLOSE 语句中指定的游标未打开。 SQLSTATE=24501;
nested exception is COM.ibm.db2.jdbc.DB2Exception: [IBM][CLI Driver][DB2/NT] SQL0501N 在 FETCH 或 CLOSE 语句中指定的游标未打开。 SQLSTATE=24501

...全文
272 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
ll42002 2006-06-17
  • 打赏
  • 举报
回复
首先,sql语句可以执行正常,应该没有问题
其次,检查程序,看hibernate session及其他数据库资源在用完后是否被关闭,包括异常情况,这个比较重要,
最后,如果还没有解决的话,建议还驱动程序的最新稳定版本试试。
wgcniler 2006-05-04
  • 打赏
  • 举报
回复
可是同样的语句结构我也用过但是并没有出错!并且上面的语句如果有错误为什么有的时候还能通过?请大家指正。
imA 2006-05-01
  • 打赏
  • 举报
回复
sql语句有错误。

把count(*)去掉。

256

社区成员

发帖
与我相关
我的任务
社区描述
其他产品/厂家
社区管理员
  • 其他
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧