mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
add mysql-driver-6 support.
This commit is contained in:
@@ -475,7 +475,7 @@
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
<version>6.0.3</version>
|
||||
<version>5.1.39</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
||||
@@ -45,6 +45,7 @@ public interface JdbcConstants {
|
||||
|
||||
public static final String MYSQL = "mysql";
|
||||
public static final String MYSQL_DRIVER = "com.mysql.jdbc.Driver";
|
||||
public static final String MYSQL_DRIVER_6 = "com.mysql.cj.jdbc.Driver";
|
||||
|
||||
public static final String MARIADB = "mariadb";
|
||||
public static final String MARIADB_DRIVER = "org.mariadb.jdbc.Driver";
|
||||
|
||||
@@ -50,6 +50,8 @@ public final class JdbcUtils implements JdbcConstants {
|
||||
|
||||
private static final Properties DRIVER_URL_MAPPING = new Properties();
|
||||
|
||||
private static Boolean mysql_driver_version_6 = null;
|
||||
|
||||
static {
|
||||
try {
|
||||
ClassLoader ctxClassLoader = Thread.currentThread().getContextClassLoader();
|
||||
@@ -364,7 +366,15 @@ public final class JdbcUtils implements JdbcConstants {
|
||||
if (rawUrl.startsWith("jdbc:derby:")) {
|
||||
return "org.apache.derby.jdbc.EmbeddedDriver";
|
||||
} else if (rawUrl.startsWith("jdbc:mysql:")) {
|
||||
return MYSQL_DRIVER;
|
||||
if (mysql_driver_version_6 == null) {
|
||||
mysql_driver_version_6 = Utils.loadClass("com.mysql.cj.jdbc.Driver") != null;
|
||||
}
|
||||
|
||||
if (mysql_driver_version_6) {
|
||||
return MYSQL_DRIVER_6;
|
||||
} else {
|
||||
return MYSQL_DRIVER;
|
||||
}
|
||||
} else if (rawUrl.startsWith("jdbc:log4jdbc:")) {
|
||||
return LOG4JDBC_DRIVER;
|
||||
} else if (rawUrl.startsWith("jdbc:mariadb:")) {
|
||||
|
||||
Reference in New Issue
Block a user