I made a prepared statement for DB access, it dosent work though.. I’m not really sure what the problem is.
What it should do is take a integer and a string and update the DB according to this.
Here is the code.
The connection to the DB itself works, this i know cause i can execute “normal” statements.
public void updateShipment(int shipmentNumber, String currentLocation)
throws SQLException {
String sql = "UPDATE shipments SET current_node=? WHERE shipment_id=?";
con.setAutoCommit(false);
pre = con.prepareStatement(sql);
pre.setInt(1, shipmentNumber);
pre.setString(2, currentLocation);
pre.executeUpdate();
con.commit();
pre.close();
con.setAutoCommit(true);
}
Looks like you get parameter 1 and 2 mixed up when you set them. Did you mean: