您的位置:首页 > 编程语言 > Java开发

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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: