diff --git a/easysql-api/pom.xml b/easysql-api/pom.xml
index 5068b42..836ecec 100644
--- a/easysql-api/pom.xml
+++ b/easysql-api/pom.xml
@@ -5,7 +5,7 @@
cc.carm.lib
easysql-parent
- 0.2.2
+ 0.2.3
4.0.0
diff --git a/easysql-beecp/pom.xml b/easysql-beecp/pom.xml
index 04eee2c..7e385ee 100644
--- a/easysql-beecp/pom.xml
+++ b/easysql-beecp/pom.xml
@@ -5,7 +5,7 @@
easysql-parent
cc.carm.lib
- 0.2.2
+ 0.2.3
4.0.0
diff --git a/easysql-beecp/src/main/java/cc/carm/lib/easysql/EasySQL.java b/easysql-beecp/src/main/java/cc/carm/lib/easysql/EasySQL.java
index 166c102..8f1c87b 100644
--- a/easysql-beecp/src/main/java/cc/carm/lib/easysql/EasySQL.java
+++ b/easysql-beecp/src/main/java/cc/carm/lib/easysql/EasySQL.java
@@ -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());
+ }
+
}
diff --git a/easysql-demo/pom.xml b/easysql-demo/pom.xml
index ccbc99c..54ba132 100644
--- a/easysql-demo/pom.xml
+++ b/easysql-demo/pom.xml
@@ -5,7 +5,7 @@
easysql-parent
cc.carm.lib
- 0.2.2
+ 0.2.3
4.0.0
diff --git a/easysql-hikaricp/pom.xml b/easysql-hikaricp/pom.xml
index 393a50a..1b5e7dc 100644
--- a/easysql-hikaricp/pom.xml
+++ b/easysql-hikaricp/pom.xml
@@ -5,7 +5,7 @@
easysql-parent
cc.carm.lib
- 0.2.2
+ 0.2.3
4.0.0
diff --git a/easysql-hikaricp/src/main/java/easysql/EasySQL.java b/easysql-hikaricp/src/main/java/easysql/EasySQL.java
index 7a592ab..1b57170 100644
--- a/easysql-hikaricp/src/main/java/easysql/EasySQL.java
+++ b/easysql-hikaricp/src/main/java/easysql/EasySQL.java
@@ -1,5 +1,8 @@
package 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 com.zaxxer.hikari.HikariConfig;
import com.zaxxer.hikari.HikariDataSource;
@@ -29,4 +32,25 @@ public class EasySQL {
return new SQLManagerImpl(new HikariDataSource(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 HikariDataSource) {
+ //Close hikari pool
+ ((HikariDataSource) manager.getDataSource()).close();
+ }
+ }
+
+ public static void shutdownManager(SQLManager manager) {
+ shutdownManager(manager, true, manager.isDebugMode());
+ }
+
}
diff --git a/easysql-impl/pom.xml b/easysql-impl/pom.xml
index 7d6aa52..2a3e4f6 100644
--- a/easysql-impl/pom.xml
+++ b/easysql-impl/pom.xml
@@ -5,7 +5,7 @@
easysql-parent
cc.carm.lib
- 0.2.2
+ 0.2.3
4.0.0
diff --git a/easysql-impl/src/main/java/cc/carm/lib/easysql/manager/SQLManagerImpl.java b/easysql-impl/src/main/java/cc/carm/lib/easysql/manager/SQLManagerImpl.java
index 64d2dc5..1926cac 100644
--- a/easysql-impl/src/main/java/cc/carm/lib/easysql/manager/SQLManagerImpl.java
+++ b/easysql-impl/src/main/java/cc/carm/lib/easysql/manager/SQLManagerImpl.java
@@ -5,10 +5,10 @@ import cc.carm.lib.easysql.action.PreparedSQLUpdateActionImpl;
import cc.carm.lib.easysql.action.SQLUpdateActionImpl;
import cc.carm.lib.easysql.action.SQLUpdateBatchActionImpl;
import cc.carm.lib.easysql.api.SQLManager;
-import cc.carm.lib.easysql.api.action.query.SQLQuery;
import cc.carm.lib.easysql.api.action.PreparedSQLUpdateAction;
import cc.carm.lib.easysql.api.action.PreparedSQLUpdateBatchAction;
import cc.carm.lib.easysql.api.action.SQLUpdateBatchAction;
+import cc.carm.lib.easysql.api.action.query.SQLQuery;
import cc.carm.lib.easysql.api.builder.*;
import cc.carm.lib.easysql.builder.impl.*;
import org.jetbrains.annotations.NotNull;
diff --git a/pom.xml b/pom.xml
index a73a1ed..2e4fc95 100644
--- a/pom.xml
+++ b/pom.xml
@@ -16,7 +16,7 @@
cc.carm.lib
easysql-parent
pom
- 0.2.2
+ 0.2.3
easysql-api