Skip to content

Commit

Permalink
edit connection pool
Browse files Browse the repository at this point in the history
  • Loading branch information
dev-khg committed Dec 21, 2023
1 parent 90d885f commit 9198d57
Showing 1 changed file with 15 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import com.catcher.batch.infrastructure.utils.KmsUtils;
import com.jcraft.jsch.JSch;
import com.jcraft.jsch.Session;
import com.zaxxer.hikari.HikariConfig;
import com.zaxxer.hikari.HikariDataSource;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.jdbc.DataSourceBuilder;
Expand All @@ -11,6 +13,7 @@
import org.springframework.jdbc.datasource.DriverManagerDataSource;

import javax.sql.DataSource;
import java.util.Properties;

@Configuration
@RequiredArgsConstructor
Expand Down Expand Up @@ -69,10 +72,17 @@ public DataSource dataSource() throws Exception {
localPort
);

return DataSourceBuilder.create()
.url(kmsUtils.decrypt(databaseUrl).replace(Integer.toString(localPort), Integer.toString(assignedPort)))
.username(kmsUtils.decrypt(databaseUsername))
.password(kmsUtils.decrypt(databasePassword))
.build();
Properties properties = new Properties();
properties.setProperty("driverClassName", "org.mariadb.jdbc.Driver");
properties.setProperty("jdbcUrl", kmsUtils.decrypt(databaseUrl).replace(Integer.toString(localPort), Integer.toString(assignedPort)));
properties.setProperty("maxLifetime", "179000");
properties.setProperty("idleTimeout", "185000");
properties.setProperty("password", kmsUtils.decrypt(databasePassword));
properties.setProperty("username", kmsUtils.decrypt(databaseUsername));
properties.setProperty("leakDetectionThreshold", "60000");
properties.setProperty("maximumPoolSize", "5");
properties.setProperty("minimumIdle", "5");

return new HikariDataSource(new HikariConfig(properties));
}
}

0 comments on commit 9198d57

Please sign in to comment.