1.3.0 update
This commit is contained in:
parent
096ccea733
commit
3a9bd966aa
|
|
@ -3,4 +3,4 @@
|
|||
org.gradle.jvmargs=-Xmx3G
|
||||
org.gradle.daemon=false
|
||||
|
||||
mod_version=1.16.5-1.2.2
|
||||
mod_version=1.16.5-1.3.0
|
||||
|
|
@ -38,7 +38,7 @@ public class PlayerSync
|
|||
|
||||
@SubscribeEvent
|
||||
public void onServerStarting(FMLServerStartingEvent event) throws SQLException {
|
||||
JDBCsetUp.executeUpdate("CREATE DATABASE IF NOT EXISTS "+JdbcConfig.DATABASE_NAME.get()+";",1);
|
||||
JDBCsetUp.executeUpdate("CREATE DATABASE IF NOT EXISTS `playersync`;",1);
|
||||
|
||||
JDBCsetUp.executeUpdate("CREATE TABLE IF NOT EXISTS player_data (uuid CHAR(36) NOT NULL," +
|
||||
"inventory MEDIUMBLOB,armor BLOB,advancements BLOB,enderchest MEDIUMBLOB,effects BLOB," +
|
||||
|
|
@ -53,7 +53,7 @@ public class PlayerSync
|
|||
"last_update=" + current + ";");
|
||||
|
||||
if(ModList.get().isLoaded("curios")) {
|
||||
JDBCsetUp.executeUpdate("CREATE TABLE IF NOT EXISTS curios (uuid CHAR(36) NOT NULL,curios_item BLOB, PRIMARY KEY (uuid));");
|
||||
JDBCsetUp.executeUpdate("CREATE TABLE IF NOT EXISTS curios (uuid CHAR(36) NOT NULL,curios_item BLOB, PRIMARY KEY (uuid))");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@ import java.util.Random;
|
|||
public class JdbcConfig {
|
||||
public static ForgeConfigSpec COMMON_CONFIG;
|
||||
public static ForgeConfigSpec.ConfigValue<String> HOST;
|
||||
public static ForgeConfigSpec.ConfigValue<String> DATABASE_NAME;
|
||||
public static ForgeConfigSpec.IntValue PORT;
|
||||
public static ForgeConfigSpec.ConfigValue<String> USERNAME;
|
||||
public static ForgeConfigSpec.ConfigValue<String> PASSWORD;
|
||||
|
|
@ -26,7 +25,6 @@ public class JdbcConfig {
|
|||
ForgeConfigSpec.Builder COMMON_BUILDER = new ForgeConfigSpec.Builder();
|
||||
COMMON_BUILDER.comment("General settings").push("general");
|
||||
HOST=COMMON_BUILDER.comment("The host of the database").define("host", "localhost");
|
||||
DATABASE_NAME= COMMON_BUILDER.comment("Database name").define("database_name", "playersync");
|
||||
PORT = COMMON_BUILDER.comment("database port").defineInRange("db_port", 3306, 0, 65535);
|
||||
USE_SSL = COMMON_BUILDER.comment("whether use SSL").define("use_ssl", false);
|
||||
USERNAME = COMMON_BUILDER.comment("username").define("user_name", "root");
|
||||
|
|
|
|||
|
|
@ -14,25 +14,28 @@ public class JDBCsetUp {
|
|||
|
||||
public static QueryResult executeQuery(String sql) throws SQLException{
|
||||
Connection connection = getConnection();
|
||||
PreparedStatement useStatement = connection.prepareStatement("USE `playersync`");
|
||||
useStatement.executeUpdate();
|
||||
|
||||
PreparedStatement useStatement = connection.prepareStatement("USE " + JdbcConfig.DATABASE_NAME.get());
|
||||
useStatement.executeUpdate();
|
||||
|
||||
PreparedStatement queryStatement = connection.prepareStatement(sql);
|
||||
ResultSet resultSet =queryStatement.executeQuery();
|
||||
PreparedStatement queryStatement = connection.prepareStatement(sql);
|
||||
ResultSet resultSet = queryStatement.executeQuery();
|
||||
return new QueryResult(connection,resultSet);
|
||||
}
|
||||
|
||||
public static int executeUpdate(String sql) throws SQLException{
|
||||
return executeUpdate(sql,0);
|
||||
}
|
||||
|
||||
public static int executeUpdate(String sql,int init) throws SQLException{
|
||||
try (Connection connection = getConnection()) {
|
||||
|
||||
if(init==0){
|
||||
sql="USE " + JdbcConfig.DATABASE_NAME.get() +";" + sql;
|
||||
PreparedStatement useStatement = connection.prepareStatement("USE `playersync`");
|
||||
useStatement.executeUpdate();
|
||||
|
||||
try (PreparedStatement updateStatement = connection.prepareStatement(sql)) {
|
||||
return updateStatement.executeUpdate();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static int executeUpdate(String sql,int i) throws SQLException{
|
||||
try (Connection connection = getConnection()) {
|
||||
|
||||
try (PreparedStatement updateStatement = connection.prepareStatement(sql)) {
|
||||
return updateStatement.executeUpdate();
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user