switch to mariadb

This commit is contained in:
spacerocket62 2020-10-28 19:35:14 -07:00
parent 6a0aa89410
commit ebd86d8ec7
6 changed files with 16 additions and 10 deletions

View File

@ -58,6 +58,12 @@
<version>3.3.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.mariadb.jdbc</groupId>
<artifactId>mariadb-java-client</artifactId>
<version>2.6.2</version>
<scope>compile</scope>
</dependency>
</dependencies>
<build>

View File

@ -21,7 +21,7 @@ import org.bukkit.plugin.java.JavaPlugin;
@Setter
public class Plex extends JavaPlugin
{
public static Plex plugin;
private static Plex plugin;
public MainConfig config;
private StorageType storageType = StorageType.SQLITE;

View File

@ -2,5 +2,5 @@ package me.totalfreedom.plex;
public class PlexBase
{
protected static Plex plugin = Plex.plugin;
protected static Plex plugin = Plex.get();
}

View File

@ -2,15 +2,15 @@ package me.totalfreedom.plex.cache;
import com.google.common.reflect.TypeToken;
import com.google.gson.Gson;
import me.totalfreedom.plex.Plex;
import me.totalfreedom.plex.player.PlexPlayer;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;
import java.util.UUID;
import me.totalfreedom.plex.Plex;
import me.totalfreedom.plex.player.PlexPlayer;
import me.totalfreedom.plex.rank.enums.Rank;
public class SQLPlayerData
{

View File

@ -18,7 +18,6 @@ public class SQLConnection extends PlexBase
String username = plugin.config.getString("data.central.user");
String password = plugin.config.getString("data.central.password");
String database = plugin.config.getString("data.central.db");
try
{
if (plugin.config.getString("data.central.storage").equalsIgnoreCase("sqlite"))
@ -26,13 +25,14 @@ public class SQLConnection extends PlexBase
connection = DriverManager.getConnection("jdbc:sqlite:" + new File(plugin.getDataFolder(), "database.db").getAbsolutePath());
plugin.setStorageType(StorageType.SQLITE);
}
else if (plugin.config.getString("data.central.storage").equalsIgnoreCase("mysql"))
else if (plugin.config.getString("data.central.storage").equalsIgnoreCase("mariadb"))
{
connection = DriverManager.getConnection("jdbc:mysql://" + host + ":" + port + "/" + database, username, password);
Class.forName("org.mariadb.jdbc.Driver");
connection = DriverManager.getConnection("jdbc:mariadb://" + host + ":" + port + "/" + database, username, password);
Plex.get().setStorageType(StorageType.SQL);
}
}
catch (SQLException throwables)
catch (SQLException | ClassNotFoundException throwables)
{
throwables.printStackTrace();
}

View File

@ -5,7 +5,7 @@ server:
data:
central:
storage: sqlite
storage: sqlite # use mariadb, mongodb, or sqlite here
user: ""
password: ""
hostname: 127.0.0.1