public interface SqlStream extends Closeable
Connection or a DataSource
as well as all methods to query it.| Modifier and Type | Method and Description |
|---|---|
BatchUpdate |
batchUpdate(String sql)
Prepares a DML statement to provide it multiple batches of parameters.
|
Execute<CallableStatement> |
call(String sql)
Prepares a call and provides it the given parameters.
|
void |
close()
Closes the underlying
DataSource. |
static SqlStream |
connect(Connection connection)
Constructs a
SqlStream instance holding a single connection. |
static SqlStream |
connect(DataSource dataSource)
|
default void |
exec(String sql,
Object... parameters)
Shortcut for
execute(sql).with(parameters).execute(). |
Execute<PreparedStatement> |
execute(String sql)
Prepares a query.
|
default <R> Optional<R> |
first(String sql,
SqlFunction<ResultSet,R> mapping,
Object... parameters)
Shortcut for
query(sql).with(parameters).first(mapping). |
Query |
query(SqlFunction<Connection,PreparedStatement> preparer)
Manually prepares a query from a
Connection. |
default Query |
query(String sql)
Prepares a query to be executed.
|
<T> SqlStream |
registerCustomBinding(Class<T> clazz,
PreparedStatementBinderByIndex<T> preparedStatementBinderByIndex) |
Transaction |
transaction()
Opens a new transaction bound to a single connection.
|
Transaction |
transaction(Transaction.IsolationLevel isolationLevel)
Opens a new transaction bound to a single connection.
|
Update |
update(SqlFunction<Connection,PreparedStatement> preparer)
Manually prepares a DML query from a
Connection. |
default Update |
update(String sql)
Prepares a DML sql statement.
|
static SqlStream connect(Connection connection)
SqlStream instance holding a single connection.connection - the connection to useSql instanceconnect(DataSource)static SqlStream connect(DataSource dataSource)
dataSource - the datasource supplying connectionsSql instance<T> SqlStream registerCustomBinding(Class<T> clazz, PreparedStatementBinderByIndex<T> preparedStatementBinderByIndex)
Transaction transaction()
Transaction transaction(Transaction.IsolationLevel isolationLevel)
isolationLevel - the isolation level of the underlying transactionConnection.setTransactionIsolation(int)Query query(SqlFunction<Connection,PreparedStatement> preparer)
Connection.preparer - the code creating a PreparedStatement from a
Connectiondefault Query query(String sql)
Note that the query is not actually executed until a mapping method
of Query is called.
sql - the sql queryUpdate update(SqlFunction<Connection,PreparedStatement> preparer)
Connection.preparer - the code creating a PreparedStatement from a
Connectiondefault Update update(String sql)
Not that the query is not actually executed until you invoke a
method from Update.
sql - the sql queryBatchUpdate batchUpdate(String sql)
Note that the query is not actually executed until you invoke a
count method from BatchUpdate.
sql - the sql queryExecute<PreparedStatement> execute(String sql)
Note that this method is not executed until you call Execute.execute().
sql - the sql queryExecute<CallableStatement> call(String sql)
Note that this method is not executed until you call Execute.execute().
sql - the sql queryConnection.prepareCall(String)default <R> Optional<R> first(String sql, SqlFunction<ResultSet,R> mapping, Object... parameters)
query(sql).with(parameters).first(mapping).R - the type of the elements of the returned streamsql - the sql querymapping - a function to map each row to an objectparameters - parameters to apply in order to the provided queryquery(String),
Query.first(SqlFunction)default void exec(String sql, Object... parameters)
execute(sql).with(parameters).execute().sql - the sql queryparameters - parameters to apply in order to the provided queryvoid close()
DataSource.close in interface AutoCloseableclose in interface CloseableCopyright © 2019. All rights reserved.