Skip to content

Commit e003724

Browse files
committed
Update MYSQL-API version and configure connection pooling
This commit updates the version of MYSQL-Api in the pom.xml to 5.7.2. It includes the refactoring of MYSQL.java, where additional configurations for connection pool are added to prevent resource exhaustion and improve the efficiency of database-related connections.
1 parent 31fa411 commit e003724

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
<groupId>de.goldendeveloper</groupId>
77
<artifactId>MYSQL-Api</artifactId>
8-
<version>5.7.2</version>
8+
<version>5.7.3</version>
99
<packaging>jar</packaging>
1010
<url>https://github.com/Golden-Developer/MYSQL-Api</url>
1111

src/main/java/de/goldendeveloper/mysql/MYSQL.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import java.sql.*;
1111
import java.util.ArrayList;
1212
import java.util.List;
13+
import java.util.concurrent.TimeUnit;
1314

1415
/**
1516
* The MYSQL class provides methods for connecting to a MySQL server and performing operations on the server.
@@ -400,6 +401,13 @@ public Connection getConnect() {
400401
private void createConnectionConfig() {
401402
HikariConfig config = new HikariConfig();
402403
config.setJdbcUrl(jbcUrl + this.hostname + ":" + this.port);
404+
config.setMinimumIdle(5);
405+
config.setMaximumPoolSize(10);
406+
config.setConnectionTimeout(TimeUnit.SECONDS.toMillis(30));
407+
config.setIdleTimeout(TimeUnit.MINUTES.toMillis(10));
408+
config.setMaxLifetime(TimeUnit.MINUTES.toMillis(30));
409+
config.setInitializationFailTimeout(0);
410+
config.setLeakDetectionThreshold(TimeUnit.SECONDS.toMillis(60));
403411
config.setUsername(this.username);
404412
config.setPassword(this.password);
405413
try {

0 commit comments

Comments
 (0)