1

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!

3
  • 1
    There must be something you are not telling us. The statement is correct and works fine. Commented Oct 18, 2011 at 10:09
  • Interesting, from reading the error text I assumed this must be a syntactic issue, I'll go check... Commented Oct 18, 2011 at 10:12
  • 2
    Are you positive that's the line that's throwing the exception? prepareStatement appears nowhere in the stack trace that you've shown. I wouldn't expect prepareStatement to result in a call to executeQuery. Commented Oct 18, 2011 at 12:07

1 Answer 1

2

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.