1
mirror of https://github.com/CarmJos/EasySQL.git synced 2026-06-04 15:28:20 +08:00

[0.3.9] 版本更新

- `[R]` 修改项目结构,移除无用的 `easysql-tester` 模块, 整合相关测试到 `easysql-demo` 的`src/test` 下。
- `[U]` 移除`DefaultSQLExceptionHandler` 类,与 `SQLExceptionHandler` 接口下添加 `detailed()` 与 `silent()` 两种预设错误处理器,并支持通过 `SQLManager#setExceptionHandler()` 方法应用全局生效的默认错误处理器。
> 注意: 十分不建议使用 `silent()` 处理器为默认处理器!
This commit is contained in:
2022-04-09 01:22:23 +08:00
parent f00e741035
commit 0a6c8ae1a9
25 changed files with 216 additions and 363 deletions
@@ -10,6 +10,7 @@ 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.builder.*;
import cc.carm.lib.easysql.api.function.SQLExceptionHandler;
import cc.carm.lib.easysql.builder.impl.*;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -32,6 +33,8 @@ public class SQLManagerImpl implements SQLManager {
protected ExecutorService executorPool;
@NotNull Supplier<Boolean> debugMode = () -> Boolean.FALSE;
@NotNull SQLExceptionHandler exceptionHandler;
public SQLManagerImpl(@NotNull DataSource dataSource) {
this(dataSource, null);
}
@@ -45,6 +48,8 @@ public class SQLManagerImpl implements SQLManager {
thread.setDaemon(true);
return thread;
});
this.exceptionHandler = SQLExceptionHandler.detailed(getLogger());
}
@Override
@@ -85,6 +90,17 @@ public class SQLManagerImpl implements SQLManager {
return this.activeQuery;
}
@Override
public @NotNull SQLExceptionHandler getExceptionHandler() {
return this.exceptionHandler;
}
@Override
public void setExceptionHandler(@Nullable SQLExceptionHandler handler) {
if (handler == null) this.exceptionHandler = SQLExceptionHandler.detailed(getLogger());
else this.exceptionHandler = handler;
}
@Override
public Integer executeSQL(String sql) {
return new SQLUpdateActionImpl(this, sql).execute(null);