!157 修复执行"查询当前数据库类型"后未关闭数据库链接,导致当前连接池中活跃连接数达到最大连接数的bug

Merge pull request !157 from KonBAI/close_dataSource_conn
feature/model
疯狂的狮子Li 3 years ago committed by Gitee
commit 5f0481c067
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F

@ -9,6 +9,7 @@ import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import javax.sql.DataSource;
import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.SQLException;
@ -26,8 +27,8 @@ public class DataBaseHelper {
public static DataBaseType getDataBaseType() {
DynamicRoutingDataSource ds = (DynamicRoutingDataSource) SpringUtils.getBean(DataSource.class);
DataSource dataSource = ds.determineDataSource();
try {
DatabaseMetaData metaData = dataSource.getConnection().getMetaData();
try (Connection conn = dataSource.getConnection()) {
DatabaseMetaData metaData = conn.getMetaData();
String databaseProductName = metaData.getDatabaseProductName();
return DataBaseType.find(databaseProductName);
} catch (SQLException e) {

Loading…
Cancel
Save