Use statement batches to prevent SQL interruptions.

Contributed by Sahar.
This commit is contained in:
MobiusDev
2018-05-22 10:03:18 +00:00
parent ebf1e85cce
commit f5ac4e313f
24 changed files with 96 additions and 57 deletions

View File

@@ -7227,9 +7227,9 @@ public final class L2PcInstance extends L2Playable
statement.setBoolean(6, subClass.isDualClass());
statement.setInt(7, getObjectId());
statement.setInt(8, subClass.getClassIndex());
statement.execute();
statement.clearParameters();
statement.addBatch();
}
statement.executeBatch();
}
catch (Exception e)
{
@@ -7319,8 +7319,9 @@ public final class L2PcInstance extends L2Playable
statement.setInt(8, 0); // Store type 0, active buffs/debuffs.
statement.setInt(9, getClassIndex());
statement.setInt(10, ++buff_index);
statement.execute();
statement.addBatch();
}
statement.executeBatch();
}
// Skills under reuse.
@@ -7350,9 +7351,10 @@ public final class L2PcInstance extends L2Playable
statement.setInt(8, 1); // Restore type 1, skill reuse.
statement.setInt(9, getClassIndex());
statement.setInt(10, ++buff_index);
statement.execute();
statement.addBatch();
}
}
statement.executeBatch();
}
}
catch (Exception e)
@@ -7382,9 +7384,10 @@ public final class L2PcInstance extends L2Playable
ps2.setInt(3, ts.getItemObjectId());
ps2.setLong(4, ts.getReuse());
ps2.setDouble(5, ts.getStamp());
ps2.execute();
ps2.addBatch();
}
}
ps2.executeBatch();
}
}
catch (Exception e)

View File

@@ -1051,10 +1051,11 @@ public class L2PetInstance extends L2Summon
ps2.setInt(4, skill.getSubLevel());
ps2.setInt(5, info.getTime());
ps2.setInt(6, ++buff_index);
ps2.execute();
ps2.addBatch();
SummonEffectsTable.getInstance().getPetEffects().computeIfAbsent(getControlObjectId(), k -> new CopyOnWriteArrayList<>()).add(new SummonEffect(skill, info.getTime()));
}
ps2.executeBatch();
}
}
catch (Exception e)

View File

@@ -353,7 +353,7 @@ public class L2ServitorInstance extends L2Summon implements Runnable
ps2.setInt(5, skill.getLevel());
ps2.setInt(6, info.getTime());
ps2.setInt(7, ++buff_index);
ps2.execute();
ps2.addBatch();
// XXX: Rework me!
if (!SummonEffectsTable.getInstance().getServitorEffectsOwner().containsKey(getOwner().getObjectId()))
@@ -371,6 +371,7 @@ public class L2ServitorInstance extends L2Summon implements Runnable
SummonEffectsTable.getInstance().getServitorEffects(getOwner()).get(getReferenceSkill()).add(new SummonEffect(skill, info.getTime()));
}
ps2.executeBatch();
}
}
}