Experimental DB pool + fixed stat overflow on equips

Implemented EXPERIMENTAL DBCP (connection pool), trying to improve
concorrent access to DB. Added door portals on Kerning Square. Fixed
equipments getting stat overflow when upgrading stats. Fixed expiring
pets crashing the client in some cases.
This commit is contained in:
ronancpl
2017-08-23 18:01:17 -03:00
parent 36db21bf80
commit 6628e3db54
190 changed files with 18265 additions and 2183 deletions

View File

@@ -23,6 +23,7 @@ package client;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.Collection;
import java.util.Deque;
@@ -109,7 +110,9 @@ public class BuddyList {
public void loadFromDb(int characterId) {
try {
PreparedStatement ps = DatabaseConnection.getConnection().prepareStatement("SELECT b.buddyid, b.pending, b.group, c.name as buddyname FROM buddies as b, characters as c WHERE c.id = b.buddyid AND b.characterid = ?");
Connection con = DatabaseConnection.getConnection();
PreparedStatement ps = con.prepareStatement("SELECT b.buddyid, b.pending, b.group, c.name as buddyname FROM buddies as b, characters as c WHERE c.id = b.buddyid AND b.characterid = ?");
ps.setInt(1, characterId);
ResultSet rs = ps.executeQuery();
while (rs.next()) {
@@ -121,10 +124,11 @@ public class BuddyList {
}
rs.close();
ps.close();
ps = DatabaseConnection.getConnection().prepareStatement("DELETE FROM buddies WHERE pending = 1 AND characterid = ?");
ps = con.prepareStatement("DELETE FROM buddies WHERE pending = 1 AND characterid = ?");
ps.setInt(1, characterId);
ps.executeUpdate();
ps.close();
con.close();
} catch (SQLException ex) {
ex.printStackTrace();
}