From 4e6e2f3fabeeb5fcb02b10eb6794d9b3631389fc Mon Sep 17 00:00:00 2001 From: inrgihc Date: Tue, 11 Apr 2023 23:07:49 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dpostgresql=E5=90=8C=E6=AD=A5?= =?UTF-8?q?=E6=8A=A5=E9=94=99=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/gitee/dbswitch/data/util/DataSourceUtils.java | 4 +++- dbswitch-data/src/main/resources/config.yml | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/dbswitch-data/src/main/java/com/gitee/dbswitch/data/util/DataSourceUtils.java b/dbswitch-data/src/main/java/com/gitee/dbswitch/data/util/DataSourceUtils.java index b22e7068..e2e7e9a2 100644 --- a/dbswitch-data/src/main/java/com/gitee/dbswitch/data/util/DataSourceUtils.java +++ b/dbswitch-data/src/main/java/com/gitee/dbswitch/data/util/DataSourceUtils.java @@ -179,7 +179,9 @@ public final class DataSourceUtils { throw new RuntimeException(e); } }).toArray(URL[]::new); - URLClassLoader loader = new URLClassLoader(urls, null); + ClassLoader parent = driverClass.contains("postgresql") + ? Thread.currentThread().getContextClassLoader() : null; + URLClassLoader loader = new URLClassLoader(urls, parent); try { Class clazz = loader.loadClass(driverClass); clazz.newInstance(); diff --git a/dbswitch-data/src/main/resources/config.yml b/dbswitch-data/src/main/resources/config.yml index 6aa6d632..3acb85ae 100644 --- a/dbswitch-data/src/main/resources/config.yml +++ b/dbswitch-data/src/main/resources/config.yml @@ -5,7 +5,7 @@ dbswitch: ## support multiple source database connection - url: jdbc:mysql://172.17.2.10:3306/test?useUnicode=true&characterEncoding=utf-8&useSSL=false&zeroDateTimeBehavior=convertToNull&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true&tinyInt1isBit=false&rewriteBatchedStatements=true&useCompression=true driver-class-name: 'com.mysql.jdbc.Driver' - driver-path: D:/Workspace/dbswitch/drivers/mysql/mysql-5.7 + driver-path: D:/Workspace/dbswitch/drivers/mysql/mysql-5 username: 'test' password: '123456' # source database configuration parameters @@ -31,7 +31,7 @@ dbswitch: ## Best support for Oracle/PostgreSQL/Greenplum/DM etc. url: jdbc:postgresql://172.17.2.10:5432/test driver-class-name: org.postgresql.Driver - driver-path: D:/Workspace/dbswitch/driver/postgresql/postgresql-11.4 + driver-path: D:/Workspace/dbswitch/drivers/postgresql/postgresql-11.4 username: 'test' password: '123456' # target database configuration parameters