use of org.jdbi.v3.core.h2.H2DatabasePlugin in project sparrow by sparrowwallet.
the class DbPersistence method getJdbi.
private Jdbi getJdbi(Storage storage, String password) throws StorageException {
Jdbi jdbi = Jdbi.create(getDataSource(storage, password));
jdbi.installPlugin(new H2DatabasePlugin());
jdbi.installPlugin(new SqlObjectPlugin());
return jdbi;
}
use of org.jdbi.v3.core.h2.H2DatabasePlugin in project micronaut-sql by micronaut-projects.
the class JdbiFactory method jdbi.
/**
* Creates a Jdbi {@link Jdbi} instance.
* It will configure it with available Jdbi provider beans with the same qualifier.
* <p>
* Plugins will be installed automatically from the classpath using the {@link java.util.ServiceLoader} mechanism
*
* @param dataSource The {@link DataSource}
* @param transactionHandler The {@link TransactionHandler}
* @param statementBuilderFactory The {@link StatementBuilderFactory}
* @param jdbiCustomizer The {@link JdbiCustomizer}
* @return The {@link Jdbi} instance
*/
@EachBean(DataSource.class)
public Jdbi jdbi(DataSource dataSource, @Parameter @Nullable TransactionHandler transactionHandler, @Parameter @Nullable StatementBuilderFactory statementBuilderFactory, @Parameter @Nullable JdbiCustomizer jdbiCustomizer) {
Jdbi jdbi = Jdbi.create(dataSource);
// install all plugins with ServiceLoaders that are found on the classpath
jdbi.installPlugins();
// transaction handler
if (transactionHandler != null) {
jdbi.setTransactionHandler(transactionHandler);
}
// statement builder
if (statementBuilderFactory != null) {
jdbi.setStatementBuilderFactory(statementBuilderFactory);
}
// https://jdbi.org/apidocs/index.html?org/jdbi/v3/core/config/Configurable.html
if (jdbiCustomizer != null) {
jdbiCustomizer.customize(jdbi);
}
// install H2 Plugin if driver is on the classpath, as it isn't installed automatically
if (h2IsPresent()) {
jdbi.installPlugin(new H2DatabasePlugin());
}
return jdbi;
}
Aggregations