I have to develop a small program that inserts some data into an Oracle database. Unfortunately I have some trouble with a SQL Statement and the execution of it. This is the code I am using:
db.execute(
String.format("INSERT INTO tops VALUES (%d, '%s', %d, %f.00, '%s', TO_TIMESTAMP('%s', 'YYYY-MM-DD HH24:MI:SS.FF'))",
item.getID(),
item.getTitle(),
this.elements,
item.getSize(),
item.getEntity(),
timestamp.toString()));
This is the part where the execution should work but I get the following error:
java.sql.SQLException: ORA-00913: Zu viele Werte
Google Translate for exception is:
java.sql.SQLException: ORA-00913: Too many values
You can use prepared statements like this as suggested by Guallaume on the comment;