Added MySQL-Driver to Plan (Velocity support)

Affects issues:
- Close #739
This commit is contained in:
Rsl1122 2019-07-08 12:16:06 +03:00
parent 9e03a22e12
commit 3a2568d5db
4 changed files with 16 additions and 1 deletions

View File

@ -62,6 +62,7 @@ subprojects {
ext.htmlCompressorVersion = "1.5.2"
ext.caffeineVersion = "2.7.0"
ext.h2Version = "1.4.199"
ext.mysqlVersion = "8.0.16"
ext.hikariVersion = "3.3.1"
ext.slf4jVersion = "1.7.26"
ext.geoIpVersion = "2.12.0"
@ -114,7 +115,7 @@ subprojects {
// Testing dependencies required by Plan
testCompile "org.xerial:sqlite-jdbc:3.28.0" // SQLite
testCompile "mysql:mysql-connector-java:8.0.16" // MySQL
testCompile "mysql:mysql-connector-java:$mysqlVersion" // MySQL
}
configurations {

View File

@ -8,6 +8,7 @@ dependencies {
compile "com.googlecode.htmlcompressor:htmlcompressor:$htmlCompressorVersion"
compile "com.github.ben-manes.caffeine:caffeine:$caffeineVersion"
compile "com.h2database:h2:$h2Version"
compile "mysql:mysql-connector-java:$mysqlVersion"
compile "com.zaxxer:HikariCP:$hikariVersion"
compile "org.slf4j:slf4j-nop:$slf4jVersion"
compile "org.slf4j:slf4j-api:$slf4jVersion"

View File

@ -24,6 +24,7 @@ import com.djrapitops.plan.system.locale.Locale;
import com.djrapitops.plan.system.locale.lang.PluginLang;
import com.djrapitops.plan.system.settings.config.PlanConfig;
import com.djrapitops.plan.system.settings.paths.DatabaseSettings;
import com.djrapitops.plugin.api.Check;
import com.djrapitops.plugin.benchmarking.Timings;
import com.djrapitops.plugin.logging.L;
import com.djrapitops.plugin.logging.console.PluginLogger;
@ -75,12 +76,22 @@ public class MySQLDB extends SQLDB {
return DBType.MYSQL;
}
private void loadMySQLDriver() {
try {
Class.forName("com.mysql.cj.jdbc.Driver");
} catch (ClassNotFoundException e) {
errorHandler.log(L.CRITICAL, this.getClass(), e);
}
}
/**
* Setups the {@link HikariDataSource}
*/
@Override
public void setupDataSource() {
try {
if (Check.isVelocityAvailable()) loadMySQLDriver();
HikariConfig hikariConfig = new HikariConfig();
String host = config.get(DatabaseSettings.MYSQL_HOST);

View File

@ -15,6 +15,8 @@ shadowJar {
configurations = [project.configurations.compile]
relocate 'dagger', 'plan.dagger'
relocate 'com.mysql.jdbc', 'plan.com.mysql.jdbc'
relocate 'com.mysql.cj', 'plan.com.mysql.cj'
destinationDir = file("$rootDir/builds/")
baseName = "Plan"