mirror of
https://github.com/CarmJos/EasySQL.git
synced 2026-06-05 00:25:32 +08:00
[v0.2.3] 添加默认的终止manager方法,并支持强制关闭活动链接。
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>easysql-parent</artifactId>
|
||||
<groupId>cc.carm.lib</groupId>
|
||||
<version>0.2.2</version>
|
||||
<version>0.2.3</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
package cc.carm.lib.easysql;
|
||||
|
||||
import cc.carm.lib.easysql.api.SQLManager;
|
||||
import cc.carm.lib.easysql.api.action.query.SQLQuery;
|
||||
import cc.carm.lib.easysql.api.util.TimeDateUtils;
|
||||
import cc.carm.lib.easysql.manager.SQLManagerImpl;
|
||||
import cn.beecp.BeeDataSource;
|
||||
import cn.beecp.BeeDataSourceConfig;
|
||||
@@ -18,4 +21,26 @@ public class EasySQL {
|
||||
return new SQLManagerImpl(new BeeDataSource(config));
|
||||
}
|
||||
|
||||
|
||||
public static void shutdownManager(SQLManager manager, boolean forceClose, boolean outputActiveQuery) {
|
||||
if (!manager.getActiveQuery().isEmpty()) {
|
||||
manager.getLogger().severe("There are " + manager.getActiveQuery().size() + " connections still running");
|
||||
for (SQLQuery value : manager.getActiveQuery().values()) {
|
||||
if (outputActiveQuery) {
|
||||
manager.getLogger().severe("#" + value.getAction().getShortID() + " -> " + value.getSQLContent());
|
||||
manager.getLogger().severe("- execute at " + TimeDateUtils.getTimeString(value.getExecuteTime()));
|
||||
}
|
||||
if (forceClose) value.close();
|
||||
}
|
||||
}
|
||||
if (manager.getDataSource() instanceof BeeDataSource) {
|
||||
//Close bee connection pool
|
||||
((BeeDataSource) manager.getDataSource()).close();
|
||||
}
|
||||
}
|
||||
|
||||
public static void shutdownManager(SQLManager manager) {
|
||||
shutdownManager(manager, true, manager.isDebugMode());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user