Class SQLRunner
java.lang.Object
cool.scx.jdbc.sql.SQLRunner
SQLRunner 用于执行简单的 jdbc 查询
- Version:
- 0.0.1
- Author:
- scx567888
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription<T, X extends Throwable>
TautoContext(cool.scx.function.CallableX<T, X> handler) 更改上下文<X extends Throwable>
voidautoContext(cool.scx.function.RunnableX<X> handler) <T, X extends Throwable>
TautoTransaction(cool.scx.function.CallableX<T, X> handler) 自动处理事务并在产生异常时进行自动回滚<X extends Throwable>
voidautoTransaction(cool.scx.function.RunnableX<X> handler) 自动处理事务并在产生异常时进行自动回滚longexecute (自动管理连接)longexecute(Connection con, SQL sql) <T, X extends Throwable>
Tquery(SQL sql, ResultHandler<T, X> resultHandler) query (自动管理连接)<T, X extends Throwable>
Tquery(Connection con, SQL sql, ResultHandler<T, X> resultHandler) update (自动管理连接)update(Connection con, SQL sql) updateBatch(SQL sql) updateBatch (自动管理连接)updateBatch(Connection con, SQL sql) <X extends Throwable>
voidwithTransaction(cool.scx.function.ConsumerX<Connection, X> handler) <T, X extends Throwable>
TwithTransaction(cool.scx.function.FunctionX<Connection, T, X> handler) 需要用户手动提交事务
-
Constructor Details
-
SQLRunner
-
-
Method Details
-
query
public <T, X extends Throwable> T query(Connection con, SQL sql, ResultHandler<T, X> resultHandler) throws SQLException, X- Throws:
SQLExceptionX
-
execute
- Throws:
SQLException
-
update
- Throws:
SQLException
-
updateBatch
- Throws:
SQLException
-
query
public <T, X extends Throwable> T query(SQL sql, ResultHandler<T, X> resultHandler) throws SQLRunnerException, Xquery (自动管理连接)- Throws:
SQLRunnerExceptionX
-
execute
-
update
update (自动管理连接)- Throws:
SQLRunnerException
-
updateBatch
updateBatch (自动管理连接)- Throws:
SQLRunnerException
-
autoTransaction
public <T, X extends Throwable> T autoTransaction(cool.scx.function.CallableX<T, X> handler) throws X, SQLRunnerException自动处理事务并在产生异常时进行自动回滚- Throws:
XSQLRunnerException
-
autoTransaction
public <X extends Throwable> void autoTransaction(cool.scx.function.RunnableX<X> handler) throws X, SQLRunnerException 自动处理事务并在产生异常时进行自动回滚- Throws:
XSQLRunnerException
-
withTransaction
public <T, X extends Throwable> T withTransaction(cool.scx.function.FunctionX<Connection, T, X> handler) throws SQLRunnerException, X 需要用户手动提交事务- Throws:
SQLRunnerExceptionX
-
withTransaction
public <X extends Throwable> void withTransaction(cool.scx.function.ConsumerX<Connection, X> handler) throws SQLRunnerException, X - Throws:
SQLRunnerExceptionX
-
autoContext
public <T, X extends Throwable> T autoContext(cool.scx.function.CallableX<T, X> handler) throws SQLRunnerException, X更改上下文- Throws:
SQLRunnerExceptionX
-
autoContext
public <X extends Throwable> void autoContext(cool.scx.function.RunnableX<X> handler) throws SQLRunnerException, X - Throws:
SQLRunnerExceptionX
-