【发布时间】:2019-05-22 07:47:12
【问题描述】:
我有一个在 sql plus 上触发的 sql 查询,我得到了结果。当我从 java 代码中触发相同的查询 - jdbc 我得到一个异常 -
java.sql.SQLSyntaxErrorException: ORA-00933: SQL 命令不正确 结束了。
查询是
select prod_id, prod_area, prod_name, step_name,
to_char(entry_time, 'DD/MM/YYYY HH24:MI:SS') as entry_time,
round(extract(day from current_timestamp - entry_time)*1440 +
extract(hour from current_timestamp - entry_time)*60 +
extract(minute from current_timestamp - entry_time)) as pending_minutes
from prodreport
where exit_time is null;
java代码
String query = "select prod_id,prod_area,prod_name,step_name,to_char(entry_time, 'DD/MM/YYYY HH24:MI:SS') as entry_time, round(extract(day from current_timestamp - entry_time)*1440 + extract(hour from current_timestamp - entry_time)*60 + extract(minute from current_timestamp - entry_time)) as pending_minutes from prodreport where exit_time is null;"
【问题讨论】:
-
如果从查询字符串中删除尾随
;会发生什么? -
请提供您的 java 代码。 PreparedStatement 确实拆分了 SQL 并删除了分号
-
@jarlh 谢谢它的工作