Duplicate key logic makes sense here.
This commit is contained in:
@@ -87,10 +87,11 @@ public class dbWarehouseHandler extends dbHandlerBase {
|
||||
JSONObject warehouseJSON = new JSONObject(warehouse.resources);
|
||||
|
||||
try (Connection connection = DbManager.getConnection();
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `dyn_warehouse` SET `warehouse` = ? WHERE `cityUID` = ?")) {
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("INSERT INTO `dyn_warehouse` (`cityUUID`, `warehouse`) VALUES (?, ?) " +
|
||||
"ON DUPLICATE KEY UPDATE `warehouse` = VALUES(`warehouse`)")) {
|
||||
|
||||
preparedStatement.setString(2, warehouseJSON.toString());
|
||||
preparedStatement.setInt(1, warehouse.city.getObjectUUID());
|
||||
preparedStatement.setString(2, warehouseJSON.toString());
|
||||
|
||||
return (preparedStatement.executeUpdate() > 0);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user