Package guru.mikelue.jdut.jdbc.function
Class DbStatement
- java.lang.Object
-
- guru.mikelue.jdut.jdbc.function.DbStatement
-
public final class DbStatement extends Object
Utility used to buildJdbcRunnable
orJdbcSupplier
for processing aStatement
orPreparedStatement
with other dependencies(e.g.,DataRow
).
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static JdbcRunnable
buildRunnableForPreparedStatement(Connection conn, String sql, List<Object> values, Function<Object,JDBCType> jdbcTypeMapping, JdbcVoidFunction<? super PreparedStatement> executor)
Builds runnable to set-upPreparedStatement
and fed it to void function.static JdbcRunnable
buildRunnableForPreparedStatement(Connection conn, String sql, List<String> nameOfColumns, DataRow dataRow, JdbcVoidFunction<? super PreparedStatement> executor)
Builds runnable to set-upPreparedStatement
and fed it to void function.static JdbcRunnable
buildRunnableForStatement(Connection conn, JdbcVoidFunction<? super Statement> executor)
Builds runnable to set-upStatement
and fed it to void function.static <T> JdbcSupplier<T>
buildSupplierForPreparedStatement(Connection conn, String sql, List<Object> values, Function<Object,JDBCType> jdbcTypeMapping, JdbcFunction<? super PreparedStatement,? extends T> supplier)
Builds supplier to set-upPreparedStatement
and fed it to function.static <T> JdbcSupplier<T>
buildSupplierForPreparedStatement(Connection conn, String sql, List<String> nameOfColumns, DataRow dataRow, JdbcFunction<? super PreparedStatement,? extends T> supplier)
Builds supplier to set-upPreparedStatement
and fed it to function.static <T> JdbcSupplier<T>
buildSupplierForStatement(Connection conn, JdbcFunction<? super Statement,? extends T> supplier)
Builds supplier to set-upStatement
and fed it to function.
-
-
-
Method Detail
-
buildRunnableForPreparedStatement
public static JdbcRunnable buildRunnableForPreparedStatement(Connection conn, String sql, List<String> nameOfColumns, DataRow dataRow, JdbcVoidFunction<? super PreparedStatement> executor)
Builds runnable to set-upPreparedStatement
and fed it to void function.- Parameters:
conn
- The connection of database(won't be closed in the lambda)sql
- The SQL for executing statementnameOfColumns
- The sequence of columns used to call setXXX() of statementdataRow
- The data to be set into statementexecutor
- The executor for built statement- Returns:
- The instance of lambda
-
buildRunnableForPreparedStatement
public static JdbcRunnable buildRunnableForPreparedStatement(Connection conn, String sql, List<Object> values, Function<Object,JDBCType> jdbcTypeMapping, JdbcVoidFunction<? super PreparedStatement> executor)
Builds runnable to set-upPreparedStatement
and fed it to void function.- Parameters:
conn
- The connection of database(won't be closed in the lambda)sql
- The SQL for executing statementvalues
- The sequence of values used to call setXXX() of statementjdbcTypeMapping
- The type of JDBC mapping by type of dataexecutor
- The executor for built statement- Returns:
- The instance of lambda
- See Also:
PreparedStatements.setParameter(PreparedStatement, Object, JDBCType, int)
-
buildSupplierForPreparedStatement
public static <T> JdbcSupplier<T> buildSupplierForPreparedStatement(Connection conn, String sql, List<Object> values, Function<Object,JDBCType> jdbcTypeMapping, JdbcFunction<? super PreparedStatement,? extends T> supplier)
Builds supplier to set-upPreparedStatement
and fed it to function.- Type Parameters:
T
- The type of returned value- Parameters:
conn
- The connection of database(won't be closed in the lambda)sql
- The SQL for executing statementvalues
- The sequence of values used to call setXXX() of statementjdbcTypeMapping
- The type of JDBC mapping by type of datasupplier
- The supplier for built statement- Returns:
- The instance of lambda
- See Also:
PreparedStatements.setParameter(PreparedStatement, Object, JDBCType, int)
-
buildSupplierForPreparedStatement
public static <T> JdbcSupplier<T> buildSupplierForPreparedStatement(Connection conn, String sql, List<String> nameOfColumns, DataRow dataRow, JdbcFunction<? super PreparedStatement,? extends T> supplier)
Builds supplier to set-upPreparedStatement
and fed it to function.- Type Parameters:
T
- The type of returned value- Parameters:
conn
- The connection of database(won't be closed in the lambda)sql
- The SQL for executing statementnameOfColumns
- The sequence of columns used to call setXXX() of statementdataRow
- The data to be set into statementsupplier
- The supplier for built statement- Returns:
- The instance of lambda
-
buildRunnableForStatement
public static JdbcRunnable buildRunnableForStatement(Connection conn, JdbcVoidFunction<? super Statement> executor)
Builds runnable to set-upStatement
and fed it to void function.- Parameters:
conn
- The connection of database(won't be closed in the lambda)executor
- The executor for built statement- Returns:
- The instance of lambda
-
buildSupplierForStatement
public static <T> JdbcSupplier<T> buildSupplierForStatement(Connection conn, JdbcFunction<? super Statement,? extends T> supplier)
Builds supplier to set-upStatement
and fed it to function.- Type Parameters:
T
- The type of returned value- Parameters:
conn
- The connection of database(won't be closed in the lambda)supplier
- The supplier for built statement- Returns:
- The instance of lambda
-
-