Skip to content

Commit

Permalink
database parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
mlus-asuka committed Jul 19, 2024
1 parent fcfd299 commit 5666f79
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 0 additions & 2 deletions src/main/java/vip/fubuki/playersync/config/JdbcConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ public class JdbcConfig {
public static ForgeConfigSpec.BooleanValue IS_CHAT_SERVER;
public static ForgeConfigSpec.ConfigValue<String> CHAT_SERVER_IP;
public static ForgeConfigSpec.IntValue CHAT_SERVER_PORT;
public static ForgeConfigSpec.IntValue CHAT_CLIENT_PORT;

public static ForgeConfigSpec.ConfigValue<Integer> SERVER_ID;

Expand All @@ -41,7 +40,6 @@ public class JdbcConfig {
IS_CHAT_SERVER = COMMON_BUILDER.comment("Whether recieve messages from other servers as host").define("IsChatServer",false);
CHAT_SERVER_IP = COMMON_BUILDER.define("ChatServerIP","127.0.0.1");
CHAT_SERVER_PORT = COMMON_BUILDER.defineInRange("ChatServerPort",7900,0,65535);
CHAT_CLIENT_PORT = COMMON_BUILDER.defineInRange("ChatClientPort",7980,0,655535);
COMMON_BUILDER.pop();
COMMON_CONFIG = COMMON_BUILDER.build();
}
Expand Down
6 changes: 4 additions & 2 deletions src/main/java/vip/fubuki/playersync/util/JDBCsetUp.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ public static Connection getConnection() throws SQLException {

public static QueryResult executeQuery(String sql) throws SQLException{
Connection connection = getConnection();
PreparedStatement useStatement = connection.prepareStatement("USE "+JdbcConfig.DATABASE_NAME.get());
PreparedStatement useStatement = connection.prepareStatement("USE ?");
useStatement.setString(1, JdbcConfig.DATABASE_NAME.get());
useStatement.executeUpdate();

PreparedStatement queryStatement = connection.prepareStatement(sql);
Expand All @@ -25,7 +26,8 @@ public static QueryResult executeQuery(String sql) throws SQLException{
public static int executeUpdate(String sql) throws SQLException{
try (Connection connection = getConnection()) {

PreparedStatement useStatement = connection.prepareStatement("USE "+JdbcConfig.DATABASE_NAME.get());
PreparedStatement useStatement = connection.prepareStatement("USE ?");
useStatement.setString(1, JdbcConfig.DATABASE_NAME.get());
useStatement.executeUpdate();

try (PreparedStatement updateStatement = connection.prepareStatement(sql)) {
Expand Down

0 comments on commit 5666f79

Please sign in to comment.