java.sql.SQLException: ORA-00911: invalid character
2013-11-28 16:48
483 查看
控制台抛出这个异常:java.sql.SQLException: ORA-00911: invalid character
查了一下说是oracle字符集设置的问题。我将抛异常的SQL语句在控制台输出如下:select order_type as orderType, sum(case when in_amount is null then 0 else in_amount end) as inAmount, sum(case when trade_amount is null then 0 else trade_amount end) as tradeAmount, (sum(case when in_amount is null then 0 else in_amount end) -sum(case when trade_amount is null then 0 else trade_amount end)) as diffAmount from t_tb_account_check group by order_type;
以上是完完整整的输出结果,然后我将语句复制到PL/SQL中执行是完全可以的,没有任何异常的。。而我在程序中定义的sql如下:select order_type as orderType,
sum(case when in_amount is null then 0 else in_amount end) as inAmount,
sum(case when trade_amount is null then 0 else trade_amount end) as tradeAmount,
(sum(case when in_amount is null then 0 else in_amount end) -sum(case when trade_amount is null then 0 else trade_amount end)) as diffAmount
from t_tb_account_check
group by order_type;
呵呵,花费了半个多小时终于找到原因::::哈哈,,定义语句中sql后面多了一个分号。(“;”)晕菜。。这样的话在PL/SQL中是无所谓的,可是Java 的数据库驱动却不识别这样的语句了。汗,,,太大意了。记录下来防止再次犯错,呵呵。。。
本文出自 “我的JAVA世界” 博客,请务必保留此出处http://hanchaohan.blog.51cto.com/2996417/1333325
查了一下说是oracle字符集设置的问题。我将抛异常的SQL语句在控制台输出如下:select order_type as orderType, sum(case when in_amount is null then 0 else in_amount end) as inAmount, sum(case when trade_amount is null then 0 else trade_amount end) as tradeAmount, (sum(case when in_amount is null then 0 else in_amount end) -sum(case when trade_amount is null then 0 else trade_amount end)) as diffAmount from t_tb_account_check group by order_type;
以上是完完整整的输出结果,然后我将语句复制到PL/SQL中执行是完全可以的,没有任何异常的。。而我在程序中定义的sql如下:select order_type as orderType,
sum(case when in_amount is null then 0 else in_amount end) as inAmount,
sum(case when trade_amount is null then 0 else trade_amount end) as tradeAmount,
(sum(case when in_amount is null then 0 else in_amount end) -sum(case when trade_amount is null then 0 else trade_amount end)) as diffAmount
from t_tb_account_check
group by order_type;
呵呵,花费了半个多小时终于找到原因::::哈哈,,定义语句中sql后面多了一个分号。(“;”)晕菜。。这样的话在PL/SQL中是无所谓的,可是Java 的数据库驱动却不识别这样的语句了。汗,,,太大意了。记录下来防止再次犯错,呵呵。。。
本文出自 “我的JAVA世界” 博客,请务必保留此出处http://hanchaohan.blog.51cto.com/2996417/1333325
相关文章推荐
- java jdk环境变量设置
- java中hashcode()和equals()的详解
- 图文介绍如何在Eclipse统计代码行数
- java处理特殊字符乱码问题
- java 内存管理 堆和栈的理解
- java的编码风格
- ubuntu 配置java开发环境(jdk+eclipse)
- Myeclipse10使用git
- CXF java.lang.RuntimeException: Cannot create a secure XMLInputFactory
- java手册之字符串操作
- java动态代理(JDK和cglib)
- eclipse编译校验JS卡死解决办法
- java 字符串相关操作
- myeclipse10.0优化
- JAVA Calendar详解
- eclipse 国际化的插件 properties
- Java学习笔记 - 单例设计模式 (一)
- eclipse内存报错的解决方法
- Java HashMap 分析之四:查找和内存使用
- 创建支持eclipse的多模块maven项目