database parameter

This commit is contained in:
mlus 2024-07-19 23:27:54 +08:00
parent fcfd299807
commit 5666f79c88
2 changed files with 4 additions and 4 deletions

View File

@ -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;
@ -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();
}

View File

@ -14,7 +14,8 @@ public class JDBCsetUp {
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);
@ -25,7 +26,8 @@ public class JDBCsetUp {
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)) {