2 yeqiurong yeqiurong 于 2015.07.15 17:59 提问

UncategorizedSQLException异常原因

执行一条HQL语句:select t.myApp from myPageApp t where t.sysUser.id = ? and t.recordStatus = 1 and t.myApp.recordStatus = 1 ;然后就报了org.springframework.jdbc.UncategorizedSQLException异常,什么原因导致的?查了半天了,求助。
具体报错信息:
org.springframework.jdbc.UncategorizedSQLException: Hibernate operation: could not execute query; uncategorized SQLException for SQL [select deskapp1_.id as id2_, deskapp1_.apptype as apptype2_, deskapp1_.count_url as count3_2_, deskapp1_.CREATE_TIME as CREATE4_2_, deskapp1_.default_page as default5_2_, deskapp1_.depicts as depicts2_, deskapp1_.PARENT_ID as PARENT20_2_, deskapp1_.desk_icon_id as desk21_2_, deskapp1_.module_id as module22_2_, deskapp1_.ISAPP as ISAPP2_, deskapp1_.isdefault as isdefault2_, deskapp1_.isload as isload2_, deskapp1_.isresize as isresize2_, deskapp1_.NAME as NAME2_, deskapp1_.news_address as news12_2_, deskapp1_.news_height as news13_2_, deskapp1_.news_width as news14_2_, deskapp1_.page_percent as page15_2_, deskapp1_.RECORD_ORDER as RECORD16_2_, deskapp1_.RECORD_STATUS as RECORD17_2_, deskapp1_.sys_config_id as sys23_2_, deskapp1_.UPDATE_TIME as UPDATE18_2_, deskapp1_.url_address as url19_2_ from desk_page_app deskpageap0_ inner join desk_app deskapp1_ on deskpageap0_.desk_menu_id=deskapp1_.id where deskpageap0_.user_id=? and deskpageap0_.record_status=1 and deskapp1_.RECORD_STATUS=1]; SQL state [null]; error code [0]; Couldn't perform the operation prepareStatement: You can't perform any operations on this connection. It has been automatically closed by Proxool for some reason (see logs).; nested exception is java.sql.SQLException: Couldn't perform the operation prepareStatement: You can't perform any operations on this connection. It has been automatically closed by Proxool for some reason (see logs).


8个回答

Evankaka
Evankaka   Ds   Rxr 2015.07.15 18:00
已采纳

SQL 查询语句异常
把语句复制进去数据库中执行看看

yeqiurong
yeqiurong 在数据库查询没有报错呀,sql语句是这样的:select t.menu_id from my_Page_App t,my_app d where t.User_id = 5 and t.record_Status = 1 and d.recordStatus = 1 ;
2 年多之前 回复
CSDNXIAON
CSDNXIAON   2015.07.16 15:31

OutOfMemonryException异常的原因有哪些
----------------------同志你好,我是CSDN问答机器人小N,奉组织之命为你提供参考答案,编程尚未成功,同志仍需努力!

yeqiurong
yeqiurong   2015.07.15 18:34

上面的回复中我写错了表名,下面才是我真实执行的语句:
HQL:select t.deskApp from DeskPageApp t where t.sysUser.id = 5 and t.recordStatus = 1 and t.deskApp.recordStatus = 1 ;
改成sql语句:
select t.desk_menu_id from Desk_Page_App t inner JOIN desk_app d on t.record_Status = 1 and d.record_Status = 1 and t.User_id = 5;
没有报错,
但为什么在程序中会报错?

danielinbiti
danielinbiti   Ds   Rxr 2015.07.15 18:09
 elect t.myApp from myPageApp t where t.sysUser.id = ? and t.recordStatus = 1 and t.myApp.recordStatus = 1 

 这下面两个字段没看明白,什么样的字段呢,是不是写错了
 t.sysUser.id
  t.myApp.recordStatus = 1 
danielinbiti
danielinbiti 回复叶子yeah: 内部类?hibernate映射?你先看看映射对嘛
2 年多之前 回复
yeqiurong
yeqiurong 是对象, t是myPageApp对象,t里面又定义有SysUser类型对象,id是sysUser的属性,后面那个类似
2 年多之前 回复
yeqiurong
yeqiurong   2015.07.15 18:25

是对象, t是myPageApp对象,t里面又定义有SysUser类型对象,id是sysUser的属性,后面那个类似

diaoliwei2
diaoliwei2   Rxr 2015.07.15 18:53

HQL查询?你确定你的HQL映射关系是正确的吗?

yeqiurong
yeqiurong 是正确的,问题已解决。原来是数据的问题,在查这条HQL语句之前,有去查询另一条语句,得到值是null,但又要用这个值去执行后面的语句,就报错了。
2 年多之前 回复
yeqiurong
yeqiurong   2015.07.16 15:39

多谢大家热心的解答,问题已解决。

dingding_1119
dingding_1119   2017.10.12 16:16

请问你是怎么解决的?我也遇到这个问题了

Csdn user default icon
上传中...
上传图片
插入图片