use of javax.sql.CommonDataSource in project requery by requery.
the class TimeConversionsTest method setup.
@Before
public void setup() throws SQLException {
Platform platform = new HSQL();
CommonDataSource dataSource = DatabaseType.getDataSource(platform);
EntityModel model = Models.MODEL2;
Configuration configuration = new ConfigurationBuilder(dataSource, model).useDefaultLogging().setEntityCache(new EmptyEntityCache()).setWriteExecutor(Executors.newSingleThreadExecutor()).build();
SchemaModifier tables = new SchemaModifier(configuration);
tables.createTables(TableCreationMode.DROP_CREATE);
data = new EntityDataStore<>(configuration);
}
use of javax.sql.CommonDataSource in project requery by requery.
the class JPAModelTest method setup.
@Before
public void setup() throws SQLException {
CommonDataSource dataSource = DatabaseType.getDataSource(new H2());
EntityModel model = Models.JPA;
CachingProvider provider = Caching.getCachingProvider();
CacheManager cacheManager = provider.getCacheManager();
Configuration configuration = new ConfigurationBuilder(dataSource, model).useDefaultLogging().setEntityCache(new EntityCacheBuilder(model).useReferenceCache(true).useSerializableCache(true).useCacheManager(cacheManager).build()).build();
data = new EntityDataStore<>(configuration);
SchemaModifier tables = new SchemaModifier(configuration);
tables.dropTables();
TableCreationMode mode = TableCreationMode.CREATE;
System.out.println(tables.createTablesString(mode));
tables.createTables(mode);
}
use of javax.sql.CommonDataSource in project hazelcast by hazelcast.
the class WriteJdbcP method metaSupplier.
/**
* Use {@link SinkProcessors#writeJdbcP}.
*/
public static <T> ProcessorMetaSupplier metaSupplier(@Nullable String jdbcUrl, @Nonnull String updateQuery, @Nonnull SupplierEx<? extends CommonDataSource> dataSourceSupplier, @Nonnull BiConsumerEx<? super PreparedStatement, ? super T> bindFn, boolean exactlyOnce, int batchLimit) {
checkSerializable(dataSourceSupplier, "newConnectionFn");
checkSerializable(bindFn, "bindFn");
checkPositive(batchLimit, "batchLimit");
return ProcessorMetaSupplier.preferLocalParallelismOne(ConnectorPermission.jdbc(jdbcUrl, ACTION_WRITE), new ProcessorSupplier() {
private transient CommonDataSource dataSource;
@Override
public void init(@Nonnull Context context) {
dataSource = dataSourceSupplier.get();
}
@Nonnull
@Override
public Collection<? extends Processor> get(int count) {
return IntStream.range(0, count).mapToObj(i -> new WriteJdbcP<>(updateQuery, dataSource, bindFn, exactlyOnce, batchLimit)).collect(Collectors.toList());
}
@Override
public List<Permission> permissions() {
return singletonList(ConnectorPermission.jdbc(jdbcUrl, ACTION_WRITE));
}
});
}
use of javax.sql.CommonDataSource in project tomee by apache.
the class PoolDataSourceCreator method poolManagedWithRecovery.
@Override
public DataSource poolManagedWithRecovery(final String name, final XAResourceWrapper xaResourceWrapper, final String driver, final Properties properties) {
final TransactionManager transactionManager = new TransactionManagerWrapper(OpenEJB.getTransactionManager(), name, xaResourceWrapper);
final CommonDataSource ds = pool(name, driver, properties);
if (ds instanceof XADataSource) {
return new ManagedXADataSource(ds, transactionManager, SystemInstance.get().getComponent(TransactionSynchronizationRegistry.class));
}
return new ManagedDataSource(DataSource.class.cast(ds), transactionManager, SystemInstance.get().getComponent(TransactionSynchronizationRegistry.class));
}
use of javax.sql.CommonDataSource in project tomee by apache.
the class JTADataSourceWrapperFactory method create.
public CommonDataSource create() {
final TransactionManager transactionManager = OpenEJB.getTransactionManager();
CommonDataSource cds = findDelegate();
if (cds instanceof XADataSource) {
cds = new ManagedXADataSource(cds, transactionManager, SystemInstance.get().getComponent(TransactionSynchronizationRegistry.class));
} else {
cds = new ManagedDataSource(DataSource.class.cast(cds), transactionManager, SystemInstance.get().getComponent(TransactionSynchronizationRegistry.class));
}
if (logSql) {
cds = DataSourceFactory.makeItLogging(cds, logPackages);
}
return cds;
}
Aggregations