使用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& MS SQL Server,所以我猜这是与Oracle的语法差异,但在线搜索我似乎无法看到原因。为清楚起见,这是准备好的声明:
INSERT INTO fx_tv_date (id, mp, doc_id, effective, actual, stale, val) VALUES (?, ?, ?, ?, ?, ?, ?)
谢谢!
答案 0 :(得分:2)
使用的方法是excuteUpdate,而不是executeQuery来执行DML。