java.sql.SQLException: ORA-00911: invalid character

控制台抛出这个异常: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,sql,SQLException)