ORA-00933 SQL命令无法正常结束,但在SQL Developer中良好

问题描述 投票:3回答:1

我希望有人能找到什么是我的查询问题,因为我无法看到故障它和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命令未正确结束。

我的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

那么,有什么事情我会丢失?

java oracle jdbc oracle-sqldeveloper oracle12c
1个回答
4
投票

像下面的ad.ID后删除分号。你并不需要它

"ORDER BY " + 
    "ad.ID";
© www.soinside.com 2019 - 2024. All rights reserved.