throws ItemStateException {
// temporarily disable automatic reconnect feature
// since the changes need to be persisted atomically
autoReconnect = false;
try {
ItemStateException ise = null;
// number of attempts to store the changes
int trials = 2;
while (true) {
try {
super.store(changeLog);
break;
} catch (ItemStateException e) {
// catch exception and fall through...
ise = e;
}
if (ise != null && ise.getCause() instanceof SQLException
&& --trials > 0) {
// a SQLException has been thrown, try to reconnect
log.warn("storing changes failed, about to reconnect...", ise.getCause());
// try to reconnect
if (reestablishConnection()) {
// now let's give it another try
ise = null;
continue;
} else {
// reconnect failed, proceed with error processing
break;
}
}
}
if (ise == null) {
// storing the changes succeeded, now commit the changes
try {
con.commit();
} catch (SQLException e) {
String msg = "committing change log failed";
log.error(msg, e);
throw new ItemStateException(msg, e);
}
} else {
// storing the changes failed, rollback changes
try {
con.rollback();