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?