Skip to content

Commit 4f2a1d1

Browse files
author
Cobeine
committed
1.5.5
1 parent 6cd37b9 commit 4f2a1d1

File tree

6 files changed

+28
-12
lines changed

6 files changed

+28
-12
lines changed

build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ plugins {
55

66
}
77

8-
group 'me.Cobeine'
9-
version '1.5.4-SNAPSHOT'
8+
group 'github.Cobeine'
9+
version '1.5.5-SNAPSHOT'
1010

1111
repositories {
1212
mavenCentral()

sql_lava_logo.png

98.6 KB
Loading

src/main/java/me/cobeine/sqlava/connection/auth/BasicMySQLCredentials.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ public enum BasicMySQLCredentials implements CredentialsKey {
1616
PASSWORD("password", String.class,true),
1717
MAX_LIFETIME("maximumLifetime", Integer.class,true),
1818
DATASOURCE_CLASS_NAME("dataSourceClassName", String.class,false),
19+
DRIVER("JdbcDriver", String.class,false),
1920
POOL_SIZE("poolSize", Integer.class,false),
2021
JDBC_URL("jdbcUrl",String.class,false);
2122

src/main/java/me/cobeine/sqlava/connection/database/MySQLConnection.java

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@
2323
* @Author <a href="https://github.com/Cobeine">Cobeine</a>
2424
*/
2525
@Getter
26-
public class MySQLConnection implements AuthenticatedConnection<HikariDataSource>,
27-
PooledConnection<HikariDataSource, Connection> {
26+
public class MySQLConnection implements AuthenticatedConnection<HikariDataSource>, PooledConnection<HikariDataSource, Connection>{
2827

2928
private ConnectionPool<HikariDataSource,Connection> pool;
3029
private final CredentialsRecord credentialsRecord;
@@ -49,15 +48,21 @@ public void connect(Callback<Integer, Exception> callback) {
4948
@Override
5049
public ConnectionResult connect() {
5150
HikariConfig config = new HikariConfig();
52-
config.setDataSourceClassName(credentialsRecord.getProperty(BasicMySQLCredentials.DATASOURCE_CLASS_NAME, String.class));
53-
config.setMaximumPoolSize(credentialsRecord.getProperty(BasicMySQLCredentials.POOL_SIZE, Integer.class));
51+
if (credentialsRecord.getProperty(BasicMySQLCredentials.DATASOURCE_CLASS_NAME,String.class) != null) {
52+
config.setDataSourceClassName(credentialsRecord.getProperty(BasicMySQLCredentials.DATASOURCE_CLASS_NAME, String.class));
53+
}
54+
if (credentialsRecord.getProperty(BasicMySQLCredentials.DRIVER, String.class) != null) {
55+
config.setDriverClassName(credentialsRecord.getProperty(BasicMySQLCredentials.DRIVER, String.class));
56+
}
5457
if (credentialsRecord.getProperty(BasicMySQLCredentials.JDBC_URL,String.class) != null) {
5558
config.setJdbcUrl(credentialsRecord.getProperty(BasicMySQLCredentials.JDBC_URL,String.class));
5659
}
5760
if (credentialsRecord.getProperty(BasicMySQLCredentials.MAX_LIFETIME,Integer.class) != null) {
5861
config.setMaxLifetime(credentialsRecord.getProperty(BasicMySQLCredentials.MAX_LIFETIME,Integer.class));
5962
}
60-
63+
if (credentialsRecord.getProperty(BasicMySQLCredentials.POOL_SIZE,Integer.class) != null) {
64+
config.setMaximumPoolSize(credentialsRecord.getProperty(BasicMySQLCredentials.POOL_SIZE, Integer.class));
65+
}
6166
for (CredentialsKey credentialsKey : credentialsRecord.keySet()) {
6267
if (credentialsKey.isProperty()) {
6368
config.addDataSourceProperty(credentialsKey.getKey(), credentialsRecord.getProperty(credentialsKey,credentialsKey.getDataType()));

src/main/java/me/cobeine/sqlava/connection/presets/HikariDataSourcePresets.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,6 @@
99

1010
public interface HikariDataSourcePresets {
1111

12-
String DATA_SOURCE = ("com.mysql.jdbc.jdbc2.optional.MysqlDataSource");
13-
String OLD_JDBC = ("com.mysql.jdbc.Driver");
14-
String NEW_JDBC = ("com.mysql.cj.jdbc.Driver");
15-
16-
12+
String DEFAULT = ("com.mysql.jdbc.jdbc2.optional.MysqlDataSource");
1713

1814
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package me.cobeine.sqlava.connection.presets;
2+
3+
/**
4+
* @Author <a href="https://github.com/Cobeine">Cobeine</a>
5+
*/
6+
7+
public interface MysqlJDBCDriverPresets {
8+
9+
10+
String OLD_JDBC = ("com.mysql.jdbc.Driver");
11+
String NEW_JDBC = ("com.mysql.cj.jdbc.Driver");
12+
13+
14+
}

0 commit comments

Comments
 (0)