1

in my application I'm trying to insert a query into an oracle database using jdbc. I create this table:

create table TMP
(
SYNC       NUMBER,
USER       VARCHAR2(50),
DAT       DATE
)

And I use this code to insert an entry:

PreparedStatement stat=null;

    try {
        dbStatement = dbConnection.createStatement();

        String sql = "INSERT INTO TMP (USER, DAT) Values (?,?);";

        for (ReplicationHistoryDetailVO tmpEntry : entry) {
            if (tmpEntry.getSyncPhase() == REPLICATION_PHASE.DOWNLOAD) {
                stat=dbConnection.prepareStatement(sql);
                stat.setString(1, "David");
                stat.setDate(2, new Date(tmpEntry.getFinishTime()));
                stat.executeUpdate();               
            }
        }

From this code I have the following error:

Error updating database java.sql.SQLSyntaxErrorException: ORA-00911

The connection is ok. I must to write only two values, because the first value is an autoincremental key and I don't set this. Any ideas?

0

1 Answer 1

2

Try "INSERT INTO TMP (USER, DAT) Values (?,?)" without the ; at the end.

ORA-00911 is a common error for common syntax mistakes.  
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.