Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/347.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Oracle查询给出错误-SQL命令未正确结束_Java_Sql_Database_Oracle_Jdbc - Fatal编程技术网

Java Oracle查询给出错误-SQL命令未正确结束

Java Oracle查询给出错误-SQL命令未正确结束,java,sql,database,oracle,jdbc,Java,Sql,Database,Oracle,Jdbc,我正在OracleDB上手动运行下面的查询,它工作正常,并给出了结果。用适当的值替换问号 DROP TABLE EventTable PURGE CREATE GLOBAL TEMPORARY TABLE EventTable ( Module NVARCHAR2(512) NULL,EventType NVARCHAR2(512) NULL,ModuleAndEventText NVARCHAR2(512) NULL,Source NVARCHAR2(512) NULL,Severity N

我正在OracleDB上手动运行下面的查询,它工作正常,并给出了结果。用适当的值替换问号

DROP TABLE EventTable PURGE  CREATE GLOBAL TEMPORARY TABLE EventTable ( Module NVARCHAR2(512) NULL,EventType NVARCHAR2(512) NULL,ModuleAndEventText NVARCHAR2(512) NULL,Source NVARCHAR2(512) NULL,Severity NVARCHAR2(512) NULL,Node NVARCHAR2(512) NULL,UserSID NVARCHAR2(512) NULL,DesktopId NVARCHAR2(512) NULL,MachineId NVARCHAR2(512) NULL,FolderPath NVARCHAR2(512) NULL,LUNId NVARCHAR2(512) NULL,ThinAppId NVARCHAR2(512) NULL,EndpointId NVARCHAR2(512) NULL,UserDiskPathId NVARCHAR2(512) NULL,GroupId NVARCHAR2(512) NULL,EventID NUMBER NOT NULL,Time TIMESTAMP(6) NULL,Acknowledged NUMBER(38,0)NULL, PRIMARY KEY (EventID))  INSERT INTO EventTable ( Module,EventType,ModuleAndEventText,Source,Severity,Node,UserSID,DesktopId,MachineId,FolderPath,LUNId,ThinAppId,EndpointId,UserDiskPathId,GroupId,EventID,Time,Acknowledged ) SELECT Module,EventType,ModuleAndEventText,Source,Severity,Node,UserSID,DesktopId,MachineId,FolderPath,LUNId,ThinAppId,EndpointId,UserDiskPathId,GroupId,EventID,Time,Acknowledged FROM sdevent WHERE (UPPER(UserSID) = ?) AND (Time BETWEEN ? AND ?) AND ((UPPER(EventType) = ?) OR (UPPER(EventType) = ?) OR (UPPER(EventType) = ?) OR (UPPER(EventType) = ?) OR (UPPER(EventType) = ?) OR (UPPER(EventType) = ?) OR (UPPER(EventType) = ?) OR (UPPER(EventType) = ?) OR (UPPER(EventType) = ?) OR (UPPER(EventType) = ?) OR (UPPER(EventType) = ?) OR (UPPER(EventType) = ?) OR (UPPER(EventType) = ?) OR (UPPER(EventType) = ?) OR (UPPER(EventType) = ?)) SELECT COUNT(*)  FROM EventTable E  LEFT OUTER JOIN ((SELECT* FROM ( SELECT sdevent_data.eventid, name, strValue FROM sdevent_data INNER JOIN EventTable ET ON sdevent_data.eventid=ET.eventid) SourceTable PIVOT (MAX(strValue) FOR name IN ('ApplicationId','MachineId','RDSServerId','FarmId','SessionId','UserDisplayName','DesktopDisplayName','ApplicationDisplayName','MachineName','FarmDisplayName','EndUserDisplayName','ThinAppDisplayName','ProcessName','RemoteApplicationId','RemoteApplicationDescription')) PivotTable)) strValueTable ON E.eventid=strValueTable.eventid LEFT OUTER JOIN (SELECT EventID,intValue FROM sdevent_data WHERE (Name = 'ProcessId')) ProcessId ON E.EventID = ProcessId.EventID LEFT OUTER JOIN (SELECT EventID,strBlobValue FROM sdevent_data WHERE (Name = 'TimingProfilerTree')) TimingProfilerTree ON E.EventID = TimingProfilerTree.EventID WHERE (UPPER(UserSID) = ?) AND (Time BETWEEN ? AND ?) AND ((UPPER(EventType) = ?) OR (UPPER(EventType) = ?) OR (UPPER(EventType) = ?) OR (UPPER(EventType) = ?) OR (UPPER(EventType) = ?) OR (UPPER(EventType) = ?) OR (UPPER(EventType) = ?) OR (UPPER(EventType) = ?) OR (UPPER(EventType) = ?) OR (UPPER(EventType) = ?) OR (UPPER(EventType) = ?) OR (UPPER(EventType) = ?) OR (UPPER(EventType) = ?) OR (UPPER(EventType) = ?) OR (UPPER(EventType) = ?))
但是当我从JavaJDBC运行相同的查询时,它给了我一个SQL异常--

下面是创建上述查询的java代码片段--


当我打印字符串查询时,它会打印上面的查询,这很好。所以我不确定从Java运行时出了什么问题。是否有任何方法可以查看在Oracle DB中运行的与MS SQL profiler类似的实际查询?

如果查询运行正常,我怀疑查询参数可能有问题。在执行查询时设置调试点,并检查替换的参数

好的,我们将这样做,您是否怀疑上面给出的java代码中有什么可能导致问题。另外,我正在使用Oracle 18c,您能否告诉我如何启用探查器,以便我可以查看命中数据库的确切查询您显示的查询字符串包含三条SQL语句:
DROP TABLE
CREATE TABLE
INSERT
。它们需要在不同的调用中运行。
 java.sql.SQLSyntaxErrorException: ORA-00933: SQL command not properly ended

    at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:450)
    at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:399)
    at oracle.jdbc.driver.T4C8Oall.processError(T4C8Oall.java:1059)
    at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:522)
    at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:257)
    at oracle.jdbc.driver.T4C8Oall.doOALL(T4C8Oall.java:587)
    at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:225)
    at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:53)
    at oracle.jdbc.driver.T4CPreparedStatement.executeForRows(T4CPreparedStatement.java:943)
    at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1150)
StringBuilder countQuery = new StringBuilder();

       countQuery.append(" DROP TABLE EventTable PURGE ");
       countQuery.append(" CREATE GLOBAL TEMPORARY TABLE EventTable ( ");
       countQuery.append(getTempTableAttributes());
       countQuery.append(" INSERT INTO EventTable ( ");
       countQuery.append(getEventTableAttributes());
       countQuery.append(" ) SELECT ");
       countQuery.append(getEventTableAttributes());
       countQuery.append(" FROM ");
       countQuery.append(this.eventTableName);
       if (def.filter != null) {
           countQuery.append(" WHERE ");
           countQuery.append(applyFilterToQuery(def.filter));
       }
       countQuery.append(" SELECT COUNT(*) ");
       countQuery.append(" FROM ");
       countQuery.append("EventTable E ");
       countQuery.append(getLeftJoinClause());
       if (def.filter != null) {
           countQuery.append(" WHERE ");
           countQuery.append(applyFilterToQuery(def.filter));
       }
       String query = countQuery.toString();