Oracle 错误“SQL 命令未正确结束” (ORA-00933) Java 准备好的语句
使用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用的方法是 excuteUpdate,而不是 executeQuery 来执行 DML。
That method to use is excuteUpdate, not executeQuery to execute DML.