Shade MariaDB driver & add configurable driver class to config

This commit is contained in:
Govindass 2021-02-06 13:56:48 +02:00
parent 619a6831e5
commit 1ad3813c73
3 changed files with 16 additions and 0 deletions

View File

@ -80,5 +80,13 @@
<version>2.5.3</version>
<scope>provided</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.mariadb.jdbc/mariadb-java-client -->
<dependency>
<groupId>org.mariadb.jdbc</groupId>
<artifactId>mariadb-java-client</artifactId>
<version>2.7.2</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>

View File

@ -77,6 +77,8 @@ public final class SkriptDB extends JavaPlugin {
out.write("# How many connections can be awaited for simultaneously, may be useful to increase if mysql database is hosted on a separate machine to account for ping.\n");
out.write("# If it is hosted within the same machine, set it to the count of cores your processor has or the count of threads your processor can process at once.\n");
out.write("thread-pool-size: " + (Runtime.getRuntime().availableProcessors() + 1) + "\n");
out.write("# Only change this if you wish to use a different driver than Java's default, like MariaDB driver.\n");
out.write("sql-driver-class-name:" + "\"default\"" + "\n");
} catch (IOException e) {
e.printStackTrace();
}

View File

@ -1,5 +1,6 @@
package com.btk5h.skriptdb.skript;
import com.btk5h.skriptdb.SkriptDB;
import com.zaxxer.hikari.HikariDataSource;
import org.bukkit.event.Event;
@ -56,6 +57,11 @@ public class ExprDataSource extends SimpleExpression<HikariDataSource> {
}
HikariDataSource ds = new HikariDataSource();
//allow specifying of own sql driver class name
if (!SkriptDB.getInstance().getConfig().getString("sql-driver-class-name").equals("default")) {
ds.setDriverClassName(SkriptDB.getInstance().getConfig().getString("sql-driver-class-name"));
}
ds.setJdbcUrl(jdbcUrl);
if (maxLifetime != null) {