1
mirror of https://github.com/CarmJos/EasySQL.git synced 2026-06-05 00:25:32 +08:00

修改代码演示的位置

This commit is contained in:
2021-12-14 17:24:45 +08:00
parent 85d2ee8984
commit 2d384bdd15
7 changed files with 207 additions and 65 deletions
@@ -1,5 +1,7 @@
package cc.carm.lib.easysql.action.query;
import cc.carm.lib.easysql.api.SQLAction;
import cc.carm.lib.easysql.api.SQLQuery;
import cc.carm.lib.easysql.api.action.query.PreparedQueryAction;
import cc.carm.lib.easysql.manager.SQLManagerImpl;
import cc.carm.lib.easysql.query.SQLQueryImpl;
@@ -13,6 +15,7 @@ import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import java.util.function.BiConsumer;
import java.util.function.Consumer;
public class PreparedQueryActionImpl extends QueryActionImpl implements PreparedQueryAction {
@@ -66,5 +69,4 @@ public class PreparedQueryActionImpl extends QueryActionImpl implements Prepared
return new SQLQueryImpl(getManager(), this, connection, preparedStatement, resultSet);
}
}
@@ -1,6 +1,7 @@
package cc.carm.lib.easysql.action.query;
import cc.carm.lib.easysql.action.AbstractSQLAction;
import cc.carm.lib.easysql.api.SQLAction;
import cc.carm.lib.easysql.api.SQLQuery;
import cc.carm.lib.easysql.api.action.query.QueryAction;
import cc.carm.lib.easysql.manager.SQLManagerImpl;
@@ -11,6 +12,7 @@ import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.function.BiConsumer;
import java.util.function.Consumer;
public class QueryActionImpl extends AbstractSQLAction<SQLQuery> implements QueryAction {
@@ -20,7 +22,7 @@ public class QueryActionImpl extends AbstractSQLAction<SQLQuery> implements Quer
}
@Override
public @NotNull SQLQuery execute() throws SQLException {
public @NotNull SQLQueryImpl execute() throws SQLException {
Connection connection = getManager().getConnection();
Statement statement = connection.createStatement();
@@ -32,4 +34,14 @@ public class QueryActionImpl extends AbstractSQLAction<SQLQuery> implements Quer
return query;
}
@Override
public void executeAsync(Consumer<SQLQuery> success, BiConsumer<SQLException, SQLAction<SQLQuery>> failure) {
try (SQLQueryImpl query = execute()) {
if (success != null) success.accept(query);
} catch (SQLException exception) {
(exceptionHandler == null ? defaultExceptionHandler() : exceptionHandler).accept(exception, this);
}
}
}