在 Java 编程中如何处理 SQL 查询中的 xpath
我正在尝试从我的 java 应用程序执行 SQL 语句,
由于网站对 url 的限制,我已在这篇文章中替换了 http=htp 。
SELECT DISTINCT(DID)
FROM (SELECT e_id DID,
xml_doc xml,
rownum rn from employee_master_indexes)," +
" table(XMLSequence(extract(xml,'//cf:SalesReport/ext:Sales/*//j:PersonAssignedIDDetails/j:PersonID/j:ID',"+
"'xmlns:j=\" htp://www.it.jvp.com/xmm/3.0.3\"
xmlns:xsi=\" htp://www.w3.org/2001/XMLSchema\" " +
"xmlns:ext=\" htp://xml.crossflo.com/xdm/3.0.3/extension\"
xmlns:cf=\" htp://xml.crossflo.com/xdm/3.0.3\" ')))EMPID" +
"WHERE extractValue(value(EMPID),'/j:ID', 'xmlns:j=\" htp://www.it.jvp.com/xmm/3.0.3\"') LIKE '%-%-%' AND rn BETWEEN 999 AND 2001";
但最终得到
10/05/24 11:11:51 java.sql.SQLException: ORA-00933: SQL 命令未正确结束 10/05/24 11:11:51 在 oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:138) 10/05/24 11:11:51 在 oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:316) 10/05/24 11:11:51 在 oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:282) 10/05/24 11:11:51 在 oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:639) 10/05/24 11:11:51 在 oracle.jdbc.driver.T4CStatement.doOall8(T4CStatement.java:113) 10/05/24 11:11:51 在 oracle.jdbc.driver.T4CStatement.execute_for_describe(T4CStatement.java:431) 10/05/24 11:11:51 在 oracle.jdbc.driver.OracleStatement.execute_maybe_describe(OracleStatement.java:1029) 10/05/24 11:11:51 在 oracle.jdbc.driver.T4CStatement.execute_maybe_describe(T4CStatement.java:463) 10/05/24 11:11:51 在 oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1126) 10/05/24 11:11:51 在 oracle.jdbc.driver.OracleStatement.executeQuery(OracleStatement.java:1274) 10/05/24 11:11:51 在 oracle_jdbc_driver_T4CStatement_Proxy.executeQuery()
我能够在我的 sql 提示符下正确运行此查询。任何关于 Oracle 给我这个异常的指导将不胜感激。
I am trying to execute the SQL statement from my java application
Due website restriction on url I have replaced http=htp for this post.
SELECT DISTINCT(DID)
FROM (SELECT e_id DID,
xml_doc xml,
rownum rn from employee_master_indexes)," +
" table(XMLSequence(extract(xml,'//cf:SalesReport/ext:Sales/*//j:PersonAssignedIDDetails/j:PersonID/j:ID',"+
"'xmlns:j=\" htp://www.it.jvp.com/xmm/3.0.3\"
xmlns:xsi=\" htp://www.w3.org/2001/XMLSchema\" " +
"xmlns:ext=\" htp://xml.crossflo.com/xdm/3.0.3/extension\"
xmlns:cf=\" htp://xml.crossflo.com/xdm/3.0.3\" ')))EMPID" +
"WHERE extractValue(value(EMPID),'/j:ID', 'xmlns:j=\" htp://www.it.jvp.com/xmm/3.0.3\"') LIKE '%-%-%' AND rn BETWEEN 999 AND 2001";
but end up with
10/05/24 11:11:51 java.sql.SQLException: ORA-00933: SQL command not properly ended
10/05/24 11:11:51 at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:138)
10/05/24 11:11:51 at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:316)
10/05/24 11:11:51 at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:282)
10/05/24 11:11:51 at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:639)
10/05/24 11:11:51 at oracle.jdbc.driver.T4CStatement.doOall8(T4CStatement.java:113)
10/05/24 11:11:51 at oracle.jdbc.driver.T4CStatement.execute_for_describe(T4CStatement.java:431)
10/05/24 11:11:51 at oracle.jdbc.driver.OracleStatement.execute_maybe_describe(OracleStatement.java:1029)
10/05/24 11:11:51 at oracle.jdbc.driver.T4CStatement.execute_maybe_describe(T4CStatement.java:463)
10/05/24 11:11:51 at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1126)
10/05/24 11:11:51 at oracle.jdbc.driver.OracleStatement.executeQuery(OracleStatement.java:1274)
10/05/24 11:11:51 at oracle_jdbc_driver_T4CStatement_Proxy.executeQuery()
I am able to run this query properly on my sql prompt.Any guidance on what makes oracle give me this exception would be appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看起来您正在将某些子句连接到 SQL 中。您可以尝试将其放入 String 中,然后对其执行 system.out 吗?然后获取 system.out 的输出并尝试完全按照 SQL 命令提示符中的方式运行它。我打赌您很快就会发现 SQL 存在的问题。
我第二个oedo,我以前从未见过这样的SQL!
It looks like you are concatenating certain clauses to your SQL. Can you try putting it in a String and then do a system.out on it. Then take the output of system.out and trying running it exactly as is in your SQL command prompt. I bet you will quickly see the issue with the SQL there.
I second oedo, I have never seen SQL like this before!