sql-streams package.See: Description
| Interface | Description |
|---|---|
| BatchUpdate | |
| Execute<Statement extends PreparedStatement> | |
| ParameterProvider<Provider extends ParameterProvider<Provider,Statement>,Statement extends PreparedStatement> |
Represents an object holding a
PreparedStatement and providing methods
to set it up for a sql query. |
| PreparedStatementBinderByIndex<T> | |
| Query | |
| ResultSetRetrieverByIndex<T> | |
| ResultSetRetrieverByName<T> | |
| SqlStream |
This class is the main entry point from this library.
|
| StatementHolder<Statement extends PreparedStatement> |
Represents an object holding an instance of
PreparedStatement. |
| Transaction |
Represents a transaction bound to a specific
Connection. |
| Update |
| Enum | Description |
|---|---|
| Transaction.IsolationLevel |
| Exception | Description |
|---|---|
| UncheckedSqlException |
Wraps a
SQLException into an unchecked exception. |
sql-streams package.
sql-streams abstracts the JDBC API by providing tools to
easily handle set parameters of prepared statements and map database result sets to
classes.
The heart of this library is the SqlStream class which provides
static factories as well as the methods used to execute DML and DDL sql queries. These
methods generally come in two flavors: prepared and non prepared.
The prepared methods return a Prepared_____ instance implementing the ParameterProvider interface so as to allow you to set your query
parameters before executing your query. You'll most likely want to use the ParameterProvider.with(java.lang.Object...) method to set
parameters of the most common types.
The non prepared methods are generally shortcuts for the prepared methods.
You should make sure to always close instances you get from the library that
implement AutoCloseable (applies to Streams
as well). This is generally best done using the try-with-resources construct
as such:
try (PreparedUpdate update = sql.update("update salaries set amount = amount * 2")) {
// use update here
}
SqlStream.transaction(). Unlike
the JDBC API, closing a transaction (and thus the underlying connection) is guaranteed
to rollback your current transaction. As such, transactional code is best written
using the try-with-resources construct as such:
try(Transaction transaction = sql.transaction()) {
transaction.update("update salaries set amount = amount * 2");
transaction.commit();
} catch (UncheckedSqlException e) {
// Handle the exception
} // automatic rollback of uncommitted data
String, Date, Time, Timestamp, LocalDate, LocalTime and
LocalDateTime.
Query.map(be.bendem.sqlstreams.util.SqlFunction) to map
each row of the result set using your own code.Copyright © 2019. All rights reserved.