java.sql.SQLException: ORA-01722: 无效数字

本文探讨了在使用Spring MVC框架时遇到的一个关于Hibernate与Oracle数据库的异常问题,具体为在进行特定查询时出现的SQLGrammarException。通过深入分析,作者发现问题是由于在构建HQL查询字符串时,对于变量的处理方式导致了Oracle的解析错误。文章提供了修改后的代码实现,解决了这一问题,并解释了Oracle可能的解析方式,有助于理解在不同数据库环境下构建SQL查询时的注意事项。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

[eStore]2011-12-15 13:47:21,890 ERROR Probably an exception caught by Spring MVC, check the debug info which may help identifying the error. | reportError_jsp._jspService(121)
[eStore]2011-12-15 13:47:21,890 ERROR Detailed JSP Exception: | reportError_jsp._jspService(125)
org.hibernate.exception.SQLGrammarException: could not execute query
	at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:67)
	at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
	at org.hibernate.loader.Loader.doList(Loader.java:2216)


	at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
	at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
	at java.lang.Thread.run(Thread.java:595)
Caused by: java.sql.SQLException: ORA-01722: 鏃犳晥鏁板瓧

  经过多次测试发现:

String hql="from Customer t where t.telephone='"+tel+"'";//可以
String hql="from Customer t where t.telephone="+tel;//报错

 查原因:估计是oracle会将变化一下where to_numer( t.telephone)。

所以出现以上错误,转化一下试试

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值