Produce a test build to attempt to fix database not being properly set
This commit is contained in:
parent
58a732782d
commit
bd15d1f244
3 changed files with 18 additions and 4 deletions
|
@ -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.
|
||||
mod_license=GPLv3
|
||||
# The mod version. See https://semver.org/
|
||||
mod_version=1201.13.043024.0404
|
||||
mod_version=1201.13.043024.1512
|
||||
# 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.
|
||||
# See https://maven.apache.org/guides/mini/guide-naming-conventions.html
|
||||
|
|
|
@ -16,13 +16,11 @@ public class DatabaseSection
|
|||
public String user = "root";
|
||||
public String password = "";
|
||||
public String host = "localhost:3306"; // IP:port
|
||||
public String database = "savedBlocks";
|
||||
public String database = "";
|
||||
public int version;
|
||||
|
||||
public static final int VERSION = 1;
|
||||
|
||||
private boolean migrated=false;
|
||||
|
||||
public static DatabaseSection deserialize(CompoundTag tag)
|
||||
{
|
||||
DatabaseSection ret = new DatabaseSection();
|
||||
|
@ -42,6 +40,8 @@ public class DatabaseSection
|
|||
ret.database = tag.getString(TAG_DATABASE);
|
||||
}
|
||||
|
||||
|
||||
ret.version = VERSION;
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
|
@ -33,6 +33,9 @@ public class DatabaseWrapper {
|
|||
public static void start() {
|
||||
instance = new DatabaseWrapper();
|
||||
try {
|
||||
LibZontreck.LOGGER.info("Connecting to database...");
|
||||
LibZontreck.LOGGER.info("jdbc:db ://" + ServerConfig.database.user + "@" + ServerConfig.database.host + "/" + ServerConfig.database.database);
|
||||
|
||||
instance.connect(ServerConfig.database.host, ServerConfig.database.user, ServerConfig.database.password, ServerConfig.database.database);
|
||||
} catch (SQLException e) {
|
||||
throw new RuntimeException(e);
|
||||
|
@ -40,6 +43,17 @@ public class DatabaseWrapper {
|
|||
}
|
||||
|
||||
public void connect(String url, String username, String password, String database) throws SQLException {
|
||||
if(database.isBlank())
|
||||
{
|
||||
ServerConfig.init();
|
||||
if(ServerConfig.database.database.isBlank())
|
||||
{
|
||||
throw new SQLException("Failed to connect to database");
|
||||
} else {
|
||||
start();
|
||||
return;
|
||||
}
|
||||
}
|
||||
try {
|
||||
// Try MariaDB JDBC driver
|
||||
Class.forName("org.mariadb.jdbc.Driver");
|
||||
|
|
Reference in a new issue