From d57b921b4fef0da60d17c24a3a8032051c96ed4d Mon Sep 17 00:00:00 2001 From: Govindas Date: Sat, 6 Feb 2021 13:56:48 +0200 Subject: [PATCH] Shade MariaDB driver & add configurable driver class to config --- pom.xml | 8 ++++++++ src/java/com/btk5h/skriptdb/SkriptDB.java | 2 ++ src/java/com/btk5h/skriptdb/skript/ExprDataSource.java | 6 ++++++ 3 files changed, 16 insertions(+) diff --git a/pom.xml b/pom.xml index 0e2d09c..c7b6a30 100644 --- a/pom.xml +++ b/pom.xml @@ -80,5 +80,13 @@ 2.5.3 provided + + + org.mariadb.jdbc + mariadb-java-client + 2.7.2 + compile + + \ No newline at end of file diff --git a/src/java/com/btk5h/skriptdb/SkriptDB.java b/src/java/com/btk5h/skriptdb/SkriptDB.java index dfcffc8..b5354c9 100644 --- a/src/java/com/btk5h/skriptdb/SkriptDB.java +++ b/src/java/com/btk5h/skriptdb/SkriptDB.java @@ -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(); } diff --git a/src/java/com/btk5h/skriptdb/skript/ExprDataSource.java b/src/java/com/btk5h/skriptdb/skript/ExprDataSource.java index 3d9e7b0..3e68bce 100644 --- a/src/java/com/btk5h/skriptdb/skript/ExprDataSource.java +++ b/src/java/com/btk5h/skriptdb/skript/ExprDataSource.java @@ -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 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) {