public class FluentJdbc extends Object implements JdbcOperations
JdbcOperations implementation.
This class must be constructed with a DataSource that will be used
as necessary to obtain connections to the database.
import javax.sql.DataSource; import org.soulwing.jdbc.FluentJdbc; DataSource dataSource = ... // typically injected or retrieved via JNDI FluentJdbc sqlTemplate = new FluentJdbc(dataSource);A single instance of this class that is constructed with an appropriate
DataSource can be concurrently shared by an arbitrary number of
application components.| Constructor and Description |
|---|
FluentJdbc(Connection connection)
Constructs a new instance for use by a single thread.
|
FluentJdbc(DataSource dataSource)
Constructs a new instance.
|
| Modifier and Type | Method and Description |
|---|---|
JdbcCall |
call(SQLSource source)
Creates a call operation.
|
JdbcCall |
call(String sql)
Creates a call operation.
|
void |
execute(SQLSource source)
Executes a single SQL (DDL) statement.
|
void |
execute(String sql)
Executes a single SQL (DDL) statement.
|
void |
executeScript(SQLSource source)
Executes the sequence of SQL statements produced by the given source.
|
JdbcQuery<Void> |
query()
Creates a query operation.
|
<T> JdbcQuery<T> |
queryForType(Class<T> type)
Creates a query operation for objects of a given type.
|
JdbcUpdate |
update()
Creates an update operation.
|
public FluentJdbc(DataSource dataSource)
dataSource - data source that will be used to obtain connections to
the databasepublic FluentJdbc(Connection connection)
Use this constructor to create a facade instance that uses the given connection whenever a connection to the database is needed. This allows the facade to be used in conjunction with a framework such as Flyway that wants to explicit manage transaction state by providing a specific connection to each operation that needs one.
Because an instance created via this constructor uses a single database connection, it should not be used by multiple concurrent threads.
connection - connection that will be used for all JDBC operations
invoked using this facade instancepublic void execute(String sql)
execute in interface JdbcOperationssql - the SQL statement to executepublic void execute(SQLSource source)
execute in interface JdbcOperationssource - source for the SQL statement to executepublic void executeScript(SQLSource source)
executeScript in interface JdbcOperationssource - source of the SQL statements to executepublic JdbcQuery<Void> query()
This is a synonym for JdbcOperations.queryForType(Class) with Void
as the specified type. A query obtained via this method is typically
configured to use a ResultSetHandler to process returned rows.
query in interface JdbcOperationspublic <T> JdbcQuery<T> queryForType(Class<T> type)
queryForType in interface JdbcOperationstype - subject type of the queryT.public JdbcUpdate update()
update in interface JdbcOperationspublic JdbcCall call(String sql)
call in interface JdbcOperationssql - SQL call statementpublic JdbcCall call(SQLSource source)
call in interface JdbcOperationssource - source for the SQL call statementCopyright © 2014–2015 Carl Harris, Jr. All rights reserved.