Oracle 错误“SQL 命令未正确结束” (ORA-00933) Java 准备好的语句

发布于 2024-12-10 15:39:58 字数 1475 浏览 0 评论 0原文

使用 JDBC 为 Oracle 10g (10.2.0.1.0) 创建以下准备好的语句时,出现 ORA-00933:

conn.prepareStatement("INSERT INTO fx_tv_date (id, mp, doc_id, effective, actual, stale, val) VALUES (?, ?, ?, ?, ?, ?, ?)");

该行抛出以下异常...

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

  oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
  oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:331)
  oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:288)
  oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:745)
  oracle.jdbc.driver.T4CStatement.doOall8(T4CStatement.java:207)
  oracle.jdbc.driver.T4CStatement.executeForDescribe(T4CStatement.java:801)
  oracle.jdbc.driver.OracleStatement.executeMaybeDescribe(OracleStatement.java:1039)
  oracle.jdbc.driver.T4CStatement.executeMaybeDescribe(T4CStatement.java:841)
  oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1134)
  oracle.jdbc.driver.OracleStatement.executeQuery(OracleStatement.java:1274)
  org.apache.commons.dbcp.DelegatingStatement.executeQuery(DelegatingStatement.java:205)
  org.apache.commons.dbcp.DelegatingStatement.executeQuery(DelegatingStatement.java:205)

这在 MySQL 和 MySQL 中运行良好。 MS SQL Server 所以我猜这是与 Oracle 的语法差异,但在网上搜索后我似乎看不到原因。为了清楚起见,这里是准备好的声明:

INSERT INTO fx_tv_date (id, mp, doc_id, effective, actual, stale, val) VALUES (?, ?, ?, ?, ?, ?, ?)

谢谢!

I'm getting ORA-00933 when creating the following prepared statement for Oracle 10g (10.2.0.1.0) using JDBC:

conn.prepareStatement("INSERT INTO fx_tv_date (id, mp, doc_id, effective, actual, stale, val) VALUES (?, ?, ?, ?, ?, ?, ?)");

That line is throwing the following exception...

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

  oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
  oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:331)
  oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:288)
  oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:745)
  oracle.jdbc.driver.T4CStatement.doOall8(T4CStatement.java:207)
  oracle.jdbc.driver.T4CStatement.executeForDescribe(T4CStatement.java:801)
  oracle.jdbc.driver.OracleStatement.executeMaybeDescribe(OracleStatement.java:1039)
  oracle.jdbc.driver.T4CStatement.executeMaybeDescribe(T4CStatement.java:841)
  oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1134)
  oracle.jdbc.driver.OracleStatement.executeQuery(OracleStatement.java:1274)
  org.apache.commons.dbcp.DelegatingStatement.executeQuery(DelegatingStatement.java:205)
  org.apache.commons.dbcp.DelegatingStatement.executeQuery(DelegatingStatement.java:205)

This works fine in MySQL & MS SQL Server so I guess it's a syntax difference with Oracle, but having searched online I can't seem to see the cause. For clarity here's the prepared statement on its own:

INSERT INTO fx_tv_date (id, mp, doc_id, effective, actual, stale, val) VALUES (?, ?, ?, ?, ?, ?, ?)

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

ゃ懵逼小萝莉 2024-12-17 15:39:58

使用的方法是 excuteUpdate,而不是 executeQuery 来执行 DML。

That method to use is excuteUpdate, not executeQuery to execute DML.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文