Make database operations during startup consistent
Use the same Connection. and log things in a similar fashion
This commit is contained in:
@@ -19,8 +19,12 @@
|
||||
*/
|
||||
package net.server.task;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
import net.server.Server;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import tools.DatabaseConnection;
|
||||
import tools.FilePrinter;
|
||||
|
||||
/**
|
||||
@@ -28,13 +32,17 @@ import tools.FilePrinter;
|
||||
* @info Thread responsible for maintaining coupons EXP & DROP effects active
|
||||
*/
|
||||
public class CouponTask implements Runnable {
|
||||
private static final Logger log = LoggerFactory.getLogger(CouponTask.class);
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
Server.getInstance().updateActiveCoupons();
|
||||
try (Connection con = DatabaseConnection.getConnection()) {
|
||||
Server.getInstance().updateActiveCoupons(con);
|
||||
}
|
||||
Server.getInstance().commitActiveCoupons();
|
||||
} catch(SQLException sqle) {
|
||||
FilePrinter.printError(FilePrinter.EXCEPTION_CAUGHT, "Unexpected SQL error: " + sqle.getMessage());
|
||||
} catch (SQLException sqle) {
|
||||
log.error("Error updating coupon effects", sqle);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user