gpt4 book ai didi

java - ORA-00933 SQL 命令未正确结束但在 SQL Developer 中正常

转载 作者:搜寻专家 更新时间:2023-11-01 02:35:36 26 4
gpt4 key购买 nike

我希望有人能找到我的查询有什么问题,因为我看不出其中的错误,而且 Oracle SQL Developer 似乎运行与我的 Java Swing 应用程序中的代码相同的查询就好了。

我在 SQL Developer 中的查询:

SELECT 
ad.ID,ad.Script_Name,ad.Current_Status,
ad.Issues_found_during_run,ad.Testers,
ad.Run_Date,ad.Tools,u.fTag,u.role,
dbms_lob.substr(u.avatar)
FROM
allData ad
INNER JOIN
users u
ON
u.fTag = ad.lastUserWhoUpdated
GROUP BY
ad.ID,ad.Script_Name,ad.Current_Status,
ad.Issues_found_during_run,ad.Testers,
ad.Run_Date,ad.Tools,u.fTag,u.role,
dbms_lob.substr(u.avatar)
ORDER BY
ad.ID ASC;

它运行完美并返回我期望的所需记录。

但是,我的 Java Swing 应用程序中的相同查询似乎并不喜欢它,因为它给我以下错误:

java.sql.SQLSyntaxErrorException: ORA-00933: SQL command not properly ended.

我的 Java Swing 应用程序代码:

connectToDB();

String query =
"SELECT " +
"ad.ID," +
"ad.Script_Name," +
"ad.Current_Status," +
"ad.Issues_found_during_run," +
"ad.Testers," +
"ad.Run_Date," +
"ad.Tools," +
"u.fTag," +
"u.role," +
"dbms_lob.substr(u.avatar) " +
"FROM " +
"allData ad " +
"INNER JOIN " +
"users u " +
"ON " +
"u.fTag = ad.lastUserWhoUpdated " +
"GROUP BY " +
"ad.ID," +
"ad.Script_Name," +
"ad.Current_Status," +
"ad.Issues_found_during_run," +
"ad.Testers," +
"ad.Run_Date," +
"ad.Tools," +
"u.fTag," +
"u.role," +
"dbms_lob.substr(u.avatar) " +
"ORDER BY " +
"ad.ID;";

ResultSet rs = statement.executeQuery(query);
ResultSetMetaData metaData = rs.getMetaData();
etc..etc..

我对这 2 个表的结构是:

SCRIPT_NAME                  VARCHAR2(100 BYTE)
CURRENT_STATUS VARCHAR2(50 BYTE)
ISSUES_FOUND_DURING_RUN VARCHAR2(150 BYTE)
TESTERS VARCHAR2(30 BYTE)
RUN_DATE DATE
TOOLS VARCHAR2(20 BYTE)
T_SUITE NUMBER(38,0)
NOE2 VARCHAR2(5 BYTE)
NOE3 VARCHAR2(5 BYTE)
ID NUMBER(38,0)
LASTUSERWHOUPDATED NUMBER
DATELASTMOD DATE

FTAG                         NUMBER(38,0)   
ROLE VARCHAR2(15 BYTE)
AVATAR CLOB

那么,我可能会遗漏什么?

最佳答案

删除 ad.ID 后的分号,如下所示。你不需要它

"ORDER BY " + 
"ad.ID";

关于java - ORA-00933 SQL 命令未正确结束但在 SQL Developer 中正常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54598208/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com