🐛 Fixing a bug. #1120 代码生成的数据源checkDataSource是否应该关闭connection
This commit is contained in:
1 parent
1af2a227b2
commit
b864c748b6
1 file changed
+2
-9
+2
-9
@@ -135,18 +135,11 @@ public class GenDatasourceConfServiceImpl extends ServiceImpl<GenDatasourceConfM
|
||||
*/
|
||||
@Override
|
||||
public Boolean checkDataSource(GenDatasourceConf conf) {
|
||||
Connection connection =null;
|
||||
try {
|
||||
connection = DriverManager.getConnection(conf.getUrl(), conf.getUsername(), conf.getPassword());
|
||||
try (Connection connection = DriverManager.getConnection(
|
||||
conf.getUrl(), conf.getUsername(), conf.getPassword())) {
|
||||
} catch (SQLException e) {
|
||||
log.error("数据源配置 {} , 获取链接失败", conf.getName(), e);
|
||||
return Boolean.FALSE;
|
||||
}finally {
|
||||
try {
|
||||
connection.close();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return Boolean.TRUE;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user