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

feature/model
konbai 3 years ago
parent d31ed1f2e1
commit f30f3ac37b

@ -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