C
Christian
Hello
I have some problem with a prepared statement.. on a HSQLDB
String s =
"IF NOT EXISTS (SELECT 1 FROM downloadqueue WHERE tthroot = ? ) THEN "
+ "INSERT INTO downloadqueue (tthroot, date, path, priority, size)"
+ " VALUES ( ? , ? , ? , ? , ? ) "
+" ELSE "
+ "UPDATE downloadqueue SET date = ? , path = ? , priority = ? "
+ ", size = ?" + " WHERE tthroot = ? "
+ "END IF";
PreparedStatement addDQE = c.prepareStatement(s);
addDQE.setString(1, tth.toString()); //Where FAILS HERE!
addDQE.setString(2, tth.toString()); //Insert
addDQE.setLong(3, added.getTime());
addDQE.setString(4, target.getAbsolutePath());
addDQE.setInt(5, priority);
addDQE.setLong(6, size);
....
the setString fails with exception:
Invalid argument in JDBC call: parameter index out of range: 1
Why the hell not?
What can I do?
I have some problem with a prepared statement.. on a HSQLDB
String s =
"IF NOT EXISTS (SELECT 1 FROM downloadqueue WHERE tthroot = ? ) THEN "
+ "INSERT INTO downloadqueue (tthroot, date, path, priority, size)"
+ " VALUES ( ? , ? , ? , ? , ? ) "
+" ELSE "
+ "UPDATE downloadqueue SET date = ? , path = ? , priority = ? "
+ ", size = ?" + " WHERE tthroot = ? "
+ "END IF";
PreparedStatement addDQE = c.prepareStatement(s);
addDQE.setString(1, tth.toString()); //Where FAILS HERE!
addDQE.setString(2, tth.toString()); //Insert
addDQE.setLong(3, added.getTime());
addDQE.setString(4, target.getAbsolutePath());
addDQE.setInt(5, priority);
addDQE.setLong(6, size);
....
the setString fails with exception:
Invalid argument in JDBC call: parameter index out of range: 1
Why the hell not?
What can I do?