I've got an INSERT statement that works today when called from JDBC using parameters markers:
INSERT INTO errorqueue as eq (jobname, sourceid, item) VALUES(?,?,?)
In my Java code, I bind the parameters:
Connection connection=null;
PreparedStatement stmt=null;
try {
connection = getConnection();
stmt = connection.prepareStatement(sqlInsert);
stmt.setString(1, this.jobName);
stmt.setString(2, errorItem.getId());
stmt.setString(3, item.getBody());
stmt.executeUpdate();
} catch () {
...
}
I'm struggling with how I'd need to handle the parameters if I convert this to an UPSERT:
INSERT INTO errorqueue as eq (jobname, sourceid, item) VALUES(?,?,?) ON CONFLICT (jobname,sourceid) UPDATE eq SET item=? Where jobname=? and sourceid=?;
It's sneaky subtle, but in the INSERT the parameter order is (a,b,c) but in the update, the paramter binding needs to be (c,a,b)