use of org.h2.jdbcx.JdbcDataSource in project spring-boot by spring-projects.
the class DataSourceBuilderTests method buildWhenH2TypeSpecifiedReturnsExpectedDataSource.
@Test
void buildWhenH2TypeSpecifiedReturnsExpectedDataSource() {
this.dataSource = DataSourceBuilder.create().url("jdbc:h2:test").type(JdbcDataSource.class).username("test").password("secret").build();
assertThat(this.dataSource).isInstanceOf(JdbcDataSource.class);
JdbcDataSource h2DataSource = (JdbcDataSource) this.dataSource;
assertThat(h2DataSource.getUser()).isEqualTo("test");
assertThat(h2DataSource.getPassword()).isEqualTo("secret");
}
use of org.h2.jdbcx.JdbcDataSource in project java-design-patterns by iluwatar.
the class HotelTest method createDataSource.
public static DataSource createDataSource() {
JdbcDataSource dataSource = new JdbcDataSource();
dataSource.setUrl(H2_DB_URL);
return dataSource;
}
use of org.h2.jdbcx.JdbcDataSource in project ignite by apache.
the class HibernateL2CacheTransactionalSelfTest method registryBuilder.
/**
* {@inheritDoc}
*/
@Nullable
@Override
protected StandardServiceRegistryBuilder registryBuilder() {
StandardServiceRegistryBuilder builder = new StandardServiceRegistryBuilder();
DatasourceConnectionProviderImpl connProvider = new DatasourceConnectionProviderImpl();
// JTA-aware data source.
BasicManagedDataSource dataSrc = new BasicManagedDataSource();
dataSrc.setTransactionManager(jotm.getTransactionManager());
dataSrc.setDefaultAutoCommit(false);
JdbcDataSource h2DataSrc = new JdbcDataSource();
h2DataSrc.setURL(CONNECTION_URL);
dataSrc.setXaDataSourceInstance(h2DataSrc);
connProvider.setDataSource(dataSrc);
connProvider.configure(Collections.emptyMap());
builder.addService(ConnectionProvider.class, connProvider);
builder.addService(JtaPlatform.class, new TestJtaPlatform());
builder.applySetting(Environment.TRANSACTION_COORDINATOR_STRATEGY, JtaTransactionCoordinatorBuilderImpl.class.getName());
return builder;
}
use of org.h2.jdbcx.JdbcDataSource in project sql2o by aaberg.
the class H2Tests method testIssue172NPEWhenCreatingBasicDataSourceInline.
@Test
public void testIssue172NPEWhenCreatingBasicDataSourceInline() {
DataSource ds = new JdbcDataSource() {
{
setURL(url);
setUser(user);
setPassword(pass);
}
};
Sql2o sql2o = new Sql2o(ds);
assertThat(sql2o.getQuirks(), is(instanceOf(H2Quirks.class)));
}
use of org.h2.jdbcx.JdbcDataSource in project spf4j by zolyfarkas.
the class JdbcSemaphoreTest method testPerformance.
@Test
@Ignore
public void testPerformance() throws SQLException, IOException, InterruptedException, ExecutionException, TimeoutException {
int port = PORT.getAndIncrement();
Server server = Server.createTcpServer(new String[] { "-tcpPort", Integer.toString(port), "-ifNotExists" }).start();
try {
File tempDB = File.createTempFile("test", "h2db");
tempDB.deleteOnExit();
String connStr = "jdbc:h2:tcp://localhost:" + port + "/nio:" + tempDB.getAbsolutePath() + ";AUTO_SERVER=TRUE";
JdbcDataSource ds = new JdbcDataSource();
ds.setURL(connStr);
ds.setUser("sa");
ds.setPassword("sa");
createSchemaObjects(ds);
JdbcSemaphore semaphore = new JdbcSemaphore(ds, "test_sem2", 1, true);
Sampler s = new Sampler(5, 5000);
s.registerJmx();
s.start();
LOG.info("started sampling");
long deadline = TimeSource.nanoTime() + TimeUnit.SECONDS.toNanos(10);
do {
semaphore.acquire(1, 1, TimeUnit.SECONDS);
semaphore.release();
} while (deadline > TimeSource.nanoTime());
semaphore.close();
s.stop();
LOG.debug("dumped samples to {}", s.dumpToFile());
} finally {
JdbcHeartBeat.stopHeartBeats();
server.shutdown();
}
}
Aggregations