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

fix(async): 尝试修复 #49 中提到的问题

This commit is contained in:
2022-06-22 20:42:08 +08:00
parent 421fe9f454
commit 0495928e49
11 changed files with 74 additions and 19 deletions
@@ -53,10 +53,12 @@ public class QueryActionImpl extends AbstractSQLAction<SQLQuery> implements Quer
@Override
public void executeAsync(SQLHandler<SQLQuery> success, SQLExceptionHandler failure) {
try (SQLQueryImpl query = execute()) {
if (success != null) success.accept(query);
} catch (SQLException exception) {
handleException(failure, exception);
}
getManager().getExecutorPool().submit(() -> {
try (SQLQueryImpl query = execute()) {
if (success != null) success.accept(query);
} catch (SQLException exception) {
handleException(failure, exception);
}
});
}
}
@@ -89,10 +89,14 @@ public class SQLManagerImpl implements SQLManager {
return LOGGER;
}
public ExecutorService getExecutorPool() {
public @NotNull ExecutorService getExecutorPool() {
return executorPool;
}
public void setExecutorPool(@NotNull ExecutorService executorPool) {
this.executorPool = executorPool;
}
@Override
public @NotNull DataSource getDataSource() {
return this.dataSource;