Update indexes for the prepared statement

This commit is contained in:
zontreck 2024-04-24 01:27:12 -07:00
parent 4fefc79f5f
commit e0545ce9af
3 changed files with 15 additions and 15 deletions

View file

@ -53,7 +53,7 @@ mod_name=Zontreck's Library Mod
# The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default. # The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default.
mod_license=GPLv3 mod_license=GPLv3
# The mod version. See https://semver.org/ # The mod version. See https://semver.org/
mod_version=1201.13.042424.0045 mod_version=1201.13.042424.0126
# The group ID for the mod. It is only important when publishing as an artifact to a Maven repository. # The group ID for the mod. It is only important when publishing as an artifact to a Maven repository.
# This should match the base package used for the mod sources. # This should match the base package used for the mod sources.
# See https://maven.apache.org/guides/mini/guide-naming-conventions.html # See https://maven.apache.org/guides/mini/guide-naming-conventions.html

View file

@ -83,15 +83,15 @@ public abstract class BlockRestoreQueue
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
try { try {
pstmt = DatabaseWrapper.get().prepareStatement("INSERT INTO `blocks` (queueName, posX, posY, posZ, snapshotID, block) VALUES (?, ?, ?, ?, ?, ?);"); pstmt = DatabaseWrapper.get().prepareStatement("INSERT INTO `blocks` (queueName, posX, posY, posZ, snapshotID, block) VALUES (?, ?, ?, ?, ?, ?);");
pstmt.setString(0, getRestoreQueueName()); pstmt.setString(1, getRestoreQueueName());
pstmt.setInt(1, block.position.getX()); pstmt.setInt(2, block.position.getX());
pstmt.setInt(2, block.position.getY()); pstmt.setInt(3, block.position.getY());
pstmt.setInt(3, block.position.getZ()); pstmt.setInt(4, block.position.getZ());
pstmt.setInt(4, 0); pstmt.setInt(5, 0);
ByteArrayOutputStream blockState = new ByteArrayOutputStream(); ByteArrayOutputStream blockState = new ByteArrayOutputStream();
DataOutputStream dos0 = new DataOutputStream(blockState); DataOutputStream dos0 = new DataOutputStream(blockState);
NbtIo.write(block.serialize(), dos0); NbtIo.write(block.serialize(), dos0);
pstmt.setBytes(5, blockState.toByteArray()); pstmt.setBytes(6, blockState.toByteArray());
DatabaseWrapper.get().executePreparedStatement(pstmt); DatabaseWrapper.get().executePreparedStatement(pstmt);
@ -124,7 +124,7 @@ public abstract class BlockRestoreQueue
} else } else
sel = DatabaseWrapper.get().prepareStatement("SELECT * FROM `blocks` WHERE queueName=? LIMIT 1;"); sel = DatabaseWrapper.get().prepareStatement("SELECT * FROM `blocks` WHERE queueName=? LIMIT 1;");
sel.setString(0, getRestoreQueueName()); sel.setString(1, getRestoreQueueName());
ResultSet res = DatabaseWrapper.get().executePreparedStatementQuery(sel); ResultSet res = DatabaseWrapper.get().executePreparedStatementQuery(sel);
// Now retrieve the block from the database // Now retrieve the block from the database
if (res.next()) { if (res.next()) {
@ -141,10 +141,10 @@ public abstract class BlockRestoreQueue
} }
} catch (SQLException e001) { } catch (SQLException e001) {
PreparedStatement pstat = DatabaseWrapper.get().prepareStatement("DELETE FROM `blocks` WHERE queueName=? AND posX=? AND posY=? AND posZ=?;"); PreparedStatement pstat = DatabaseWrapper.get().prepareStatement("DELETE FROM `blocks` WHERE queueName=? AND posX=? AND posY=? AND posZ=?;");
pstat.setString(0, getRestoreQueueName()); pstat.setString(1, getRestoreQueueName());
pstat.setInt(1, block.position.getX()); pstat.setInt(2, block.position.getX());
pstat.setInt(2, block.position.getY()); pstat.setInt(3, block.position.getY());
pstat.setInt(3, block.position.getZ()); pstat.setInt(4, block.position.getZ());
DatabaseWrapper.get().executePreparedStatement(pstat); DatabaseWrapper.get().executePreparedStatement(pstat);
} }

View file

@ -73,8 +73,8 @@ public class DatabaseMigrations
try { try {
PreparedStatement pstat = DatabaseWrapper.get().prepareStatement("REPLACE INTO `migrations` (tableID, version) VALUES (?,?);"); PreparedStatement pstat = DatabaseWrapper.get().prepareStatement("REPLACE INTO `migrations` (tableID, version) VALUES (?,?);");
pstat.setString(0, tableID); pstat.setString(1, tableID);
pstat.setInt(1, version); pstat.setInt(2, version);
pstat.execute(); pstat.execute();
} catch (SQLException ex) } catch (SQLException ex)
@ -162,7 +162,7 @@ public class DatabaseMigrations
{ {
try{ try{
PreparedStatement pst = DatabaseWrapper.get().prepareStatement("SELECT * FROM `migrations` WHERE tableID=?;"); PreparedStatement pst = DatabaseWrapper.get().prepareStatement("SELECT * FROM `migrations` WHERE tableID=?;");
pst.setString(0, tableID); pst.setString(1, tableID);
var result = pst.executeQuery(); var result = pst.executeQuery();
if(!result.next()) if(!result.next())