23
23
* @Author <a href="https://github.com/Cobeine">Cobeine</a>
24
24
*/
25
25
@ Getter
26
- public class MySQLConnection implements AuthenticatedConnection <HikariDataSource >,
27
- PooledConnection <HikariDataSource , Connection > {
26
+ public class MySQLConnection implements AuthenticatedConnection <HikariDataSource >, PooledConnection <HikariDataSource , Connection >{
28
27
29
28
private ConnectionPool <HikariDataSource ,Connection > pool ;
30
29
private final CredentialsRecord credentialsRecord ;
@@ -49,15 +48,21 @@ public void connect(Callback<Integer, Exception> callback) {
49
48
@ Override
50
49
public ConnectionResult connect () {
51
50
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
+ }
54
57
if (credentialsRecord .getProperty (BasicMySQLCredentials .JDBC_URL ,String .class ) != null ) {
55
58
config .setJdbcUrl (credentialsRecord .getProperty (BasicMySQLCredentials .JDBC_URL ,String .class ));
56
59
}
57
60
if (credentialsRecord .getProperty (BasicMySQLCredentials .MAX_LIFETIME ,Integer .class ) != null ) {
58
61
config .setMaxLifetime (credentialsRecord .getProperty (BasicMySQLCredentials .MAX_LIFETIME ,Integer .class ));
59
62
}
60
-
63
+ if (credentialsRecord .getProperty (BasicMySQLCredentials .POOL_SIZE ,Integer .class ) != null ) {
64
+ config .setMaximumPoolSize (credentialsRecord .getProperty (BasicMySQLCredentials .POOL_SIZE , Integer .class ));
65
+ }
61
66
for (CredentialsKey credentialsKey : credentialsRecord .keySet ()) {
62
67
if (credentialsKey .isProperty ()) {
63
68
config .addDataSourceProperty (credentialsKey .getKey (), credentialsRecord .getProperty (credentialsKey ,credentialsKey .getDataType ()));
0 commit comments