Upgrade to MySQL 8

Workaround for exception thrown by ResultSet#beforeFirst():
"Operation not allowed for a result set of type ResultSet.TYPE_FORWARD_ONLY"
This commit is contained in:
P0nk
2021-04-02 14:08:41 +02:00
parent 2873d0d031
commit 05bd668cc2
3 changed files with 7 additions and 6 deletions

View File

@@ -31,7 +31,7 @@
<dependency> <dependency>
<groupId>mysql</groupId> <groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId> <artifactId>mysql-connector-java</artifactId>
<version>5.1.6</version> <version>8.0.23</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.slf4j</groupId> <groupId>org.slf4j</groupId>

View File

@@ -1620,7 +1620,9 @@ public class Server {
private static void applyAllWorldTransfers() { private static void applyAllWorldTransfers() {
try (Connection con = DatabaseConnection.getConnection(); try (Connection con = DatabaseConnection.getConnection();
PreparedStatement ps = con.prepareStatement("SELECT * FROM worldtransfers WHERE completionTime IS NULL")) { PreparedStatement ps = con.prepareStatement("SELECT * FROM worldtransfers WHERE completionTime IS NULL",
ResultSet.TYPE_SCROLL_SENSITIVE,
ResultSet.CONCUR_READ_ONLY)) {
ResultSet rs = ps.executeQuery(); ResultSet rs = ps.executeQuery();
List<Integer> removedTransfers = new LinkedList<Integer>(); List<Integer> removedTransfers = new LinkedList<Integer>();
while(rs.next()) { while(rs.next()) {

View File

@@ -30,7 +30,6 @@ import client.inventory.MapleInventoryType;
import client.inventory.manipulator.MapleInventoryManipulator; import client.inventory.manipulator.MapleInventoryManipulator;
import client.inventory.manipulator.MapleKarmaManipulator; import client.inventory.manipulator.MapleKarmaManipulator;
import client.processor.npc.FredrickProcessor; import client.processor.npc.FredrickProcessor;
import com.mysql.jdbc.Statement;
import config.YamlConfig; import config.YamlConfig;
import java.sql.Connection; import java.sql.Connection;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
@@ -309,7 +308,7 @@ public class MapleHiredMerchant extends AbstractMapleMapObject {
} }
merchantMesos += price; merchantMesos += price;
try (PreparedStatement ps = con.prepareStatement("UPDATE characters SET MerchantMesos = ? WHERE id = ?", Statement.RETURN_GENERATED_KEYS)) { try (PreparedStatement ps = con.prepareStatement("UPDATE characters SET MerchantMesos = ? WHERE id = ?", PreparedStatement.RETURN_GENERATED_KEYS)) {
ps.setInt(1, (int) Math.min(merchantMesos, Integer.MAX_VALUE)); ps.setInt(1, (int) Math.min(merchantMesos, Integer.MAX_VALUE));
ps.setInt(2, ownerId); ps.setInt(2, ownerId);
ps.executeUpdate(); ps.executeUpdate();
@@ -383,7 +382,7 @@ public class MapleHiredMerchant extends AbstractMapleMapObject {
} else { } else {
try { try {
Connection con = DatabaseConnection.getConnection(); Connection con = DatabaseConnection.getConnection();
PreparedStatement ps = con.prepareStatement("UPDATE characters SET HasMerchant = 0 WHERE id = ?", Statement.RETURN_GENERATED_KEYS); PreparedStatement ps = con.prepareStatement("UPDATE characters SET HasMerchant = 0 WHERE id = ?", PreparedStatement.RETURN_GENERATED_KEYS);
ps.setInt(1, ownerId); ps.setInt(1, ownerId);
ps.executeUpdate(); ps.executeUpdate();
@@ -442,7 +441,7 @@ public class MapleHiredMerchant extends AbstractMapleMapObject {
player.setHasMerchant(false); player.setHasMerchant(false);
} else { } else {
Connection con = DatabaseConnection.getConnection(); Connection con = DatabaseConnection.getConnection();
try (PreparedStatement ps = con.prepareStatement("UPDATE characters SET HasMerchant = 0 WHERE id = ?", Statement.RETURN_GENERATED_KEYS)) { try (PreparedStatement ps = con.prepareStatement("UPDATE characters SET HasMerchant = 0 WHERE id = ?", PreparedStatement.RETURN_GENERATED_KEYS)) {
ps.setInt(1, ownerId); ps.setInt(1, ownerId);
ps.executeUpdate(); ps.executeUpdate();
} }