Make the standard MySQL driver the default again

This commit is contained in:
Luck
2017-04-06 11:30:17 +01:00
Unverified
parent 5567b1dad8
commit 029dc9f8d9
10 changed files with 110 additions and 19 deletions
@@ -60,8 +60,8 @@ public class DependencyManager {
.put(StorageType.JSON, ImmutableList.of())
.put(StorageType.YAML, ImmutableList.of())
.put(StorageType.MONGODB, ImmutableList.of(Dependency.MONGODB_DRIVER))
.put(StorageType.MYSQL, ImmutableList.of(Dependency.MARIADB_DRIVER, Dependency.SLF4J_API, Dependency.SLF4J_SIMPLE, Dependency.HIKARI))
.put(StorageType.MYSQL_LEGACY, ImmutableList.of(Dependency.MYSQL_DRIVER, Dependency.SLF4J_API, Dependency.SLF4J_SIMPLE, Dependency.HIKARI))
.put(StorageType.MARIADB, ImmutableList.of(Dependency.MARIADB_DRIVER, Dependency.SLF4J_API, Dependency.SLF4J_SIMPLE, Dependency.HIKARI))
.put(StorageType.MYSQL, ImmutableList.of(Dependency.MYSQL_DRIVER, Dependency.SLF4J_API, Dependency.SLF4J_SIMPLE, Dependency.HIKARI))
.put(StorageType.POSTGRESQL, ImmutableList.of(Dependency.POSTGRESQL_DRIVER, Dependency.SLF4J_API, Dependency.SLF4J_SIMPLE, Dependency.HIKARI))
.put(StorageType.SQLITE, ImmutableList.of(Dependency.SQLITE_DRIVER))
.put(StorageType.H2, ImmutableList.of(Dependency.H2_DRIVER))
@@ -122,16 +122,35 @@ public class StorageFactory {
private static AbstractBacking makeBacking(StorageType method, LuckPermsPlugin plugin) {
switch (method) {
case MARIADB:
return new SQLBacking(plugin, new MySQLProvider(
"MariaDB",
"org.mariadb.jdbc.MySQLDataSource",
plugin.getConfiguration().get(ConfigKeys.DATABASE_VALUES)),
plugin.getConfiguration().get(ConfigKeys.SQL_TABLE_PREFIX)
);
case MYSQL:
return new SQLBacking(plugin, new MySQLProvider("MySQL", "org.mariadb.jdbc.MySQLDataSource", plugin.getConfiguration().get(ConfigKeys.DATABASE_VALUES)), plugin.getConfiguration().get(ConfigKeys.SQL_TABLE_PREFIX));
case MYSQL_LEGACY:
return new SQLBacking(plugin, new MySQLProvider("MySQL-Legacy", "com.mysql.jdbc.jdbc2.optional.MysqlDataSource", plugin.getConfiguration().get(ConfigKeys.DATABASE_VALUES)), plugin.getConfiguration().get(ConfigKeys.SQL_TABLE_PREFIX));
return new SQLBacking(plugin, new MySQLProvider(
"MySQL",
"com.mysql.jdbc.jdbc2.optional.MysqlDataSource",
plugin.getConfiguration().get(ConfigKeys.DATABASE_VALUES)),
plugin.getConfiguration().get(ConfigKeys.SQL_TABLE_PREFIX)
);
case SQLITE:
return new SQLBacking(plugin, new SQLiteProvider(new File(plugin.getDataDirectory(), "luckperms-sqlite.db")), plugin.getConfiguration().get(ConfigKeys.SQL_TABLE_PREFIX));
return new SQLBacking(plugin, new SQLiteProvider(
new File(plugin.getDataDirectory(), "luckperms-sqlite.db")),
plugin.getConfiguration().get(ConfigKeys.SQL_TABLE_PREFIX)
);
case H2:
return new SQLBacking(plugin, new H2Provider(new File(plugin.getDataDirectory(), "luckperms-h2")), plugin.getConfiguration().get(ConfigKeys.SQL_TABLE_PREFIX));
return new SQLBacking(plugin, new H2Provider(
new File(plugin.getDataDirectory(), "luckperms-h2")),
plugin.getConfiguration().get(ConfigKeys.SQL_TABLE_PREFIX)
);
case POSTGRESQL:
return new SQLBacking(plugin, new PostgreSQLProvider(plugin.getConfiguration().get(ConfigKeys.DATABASE_VALUES)), plugin.getConfiguration().get(ConfigKeys.SQL_TABLE_PREFIX));
return new SQLBacking(plugin, new PostgreSQLProvider(
plugin.getConfiguration().get(ConfigKeys.DATABASE_VALUES)),
plugin.getConfiguration().get(ConfigKeys.SQL_TABLE_PREFIX)
);
case MONGODB:
return new MongoDBBacking(plugin, plugin.getConfiguration().get(ConfigKeys.DATABASE_VALUES));
case YAML:
@@ -33,8 +33,8 @@ public enum StorageType {
JSON("JSON", "json", "flatfile"),
YAML("YAML", "yaml", "yml"),
MONGODB("MongoDB", "mongodb"),
MARIADB("MariaDB", "mariadb"),
MYSQL("MySQL", "mysql"),
MYSQL_LEGACY("MySQL-Legacy", "mysql-legacy"),
POSTGRESQL("PostgreSQL", "postgresql"),
SQLITE("SQLite", "sqlite"),
H2("H2", "h2");
@@ -66,7 +66,7 @@ public class MySQLProvider extends SQLProvider {
config.setUsername(username);
config.setPassword(password);
if (getName().toLowerCase().endsWith("legacy")) {
if (!getName().toLowerCase().equals("mariadb")) {
// doesn't exist on the MariaDB driver
config.addDataSourceProperty("cachePrepStmts", "true");
@@ -43,7 +43,7 @@ public class HikariSupplier implements AutoCloseable {
hikari = new HikariDataSource();
hikari.setPoolName(poolName);
hikari.setMaximumPoolSize(2);
hikari.setDataSourceClassName("org.mariadb.jdbc.Driver");
hikari.setDataSourceClassName("com.mysql.jdbc.jdbc2.optional.MysqlDataSource");
hikari.addDataSourceProperty("serverName", address.split(":")[0]);
hikari.addDataSourceProperty("port", address.split(":")[1]);
hikari.addDataSourceProperty("databaseName", database);