mirror of
https://github.com/ProjectSWGCore/NGECore2.git
synced 2026-10-14 04:13:14 -04:00
replace use of select wildcard, which uses more DB resources with a call to count the number of characters an account has in CharacterService.java
This commit is contained in:
@@ -523,10 +523,12 @@ public class CharacterService implements INetworkDispatch {
|
||||
PreparedStatement preparedStatement;
|
||||
int characters = 0;
|
||||
try {
|
||||
preparedStatement = databaseConnection.preparedStatement("SELECT * FROM characters WHERE \"accountId\"=" + accountId + "");
|
||||
preparedStatement = databaseConnection.preparedStatement("SELECT COUNT(*) AS charCount FROM characters WHERE \"accountId\"=" + accountId);
|
||||
ResultSet resultSet = preparedStatement.executeQuery();
|
||||
while(resultSet.next() && !resultSet.isClosed())
|
||||
characters++;
|
||||
|
||||
characters = 0;
|
||||
if (resultSet.next() && !resultSet.isClosed())
|
||||
characters = resultSet.getInt("charCount");
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user