use of org.jdbi.v3.core.statement.StatementBuilder in project jdbi by jdbi.
the class Jdbi method open.
/**
* Obtain a Handle to the data source wrapped by this Jdbi instance.
* You own this expensive resource and are required to close it or
* risk leaks. Using a {@code try-with-resources} block is recommended.
*
* @return an open Handle instance
* @see #useHandle(HandleConsumer)
* @see #withHandle(HandleCallback)
*/
public Handle open() {
try {
final long start = System.nanoTime();
Connection conn = connectionFactory.openConnection();
final long stop = System.nanoTime();
for (JdbiPlugin p : plugins) {
conn = p.customizeConnection(conn);
}
StatementBuilder cache = statementBuilderFactory.get().createStatementBuilder(conn);
Handle h = new Handle(config.createCopy(), transactionhandler.get(), cache, conn);
for (JdbiPlugin p : plugins) {
h = p.customizeHandle(h);
}
LOG.trace("Jdbi [{}] obtain handle [{}] in {}ms", this, h, (stop - start) / 1000000L);
return h;
} catch (SQLException e) {
throw new ConnectionException(e);
}
}
Aggregations