Search in sources :

Example 6 with JdbcDataSource

use of org.h2.jdbcx.JdbcDataSource in project che by eclipse.

the class H2TestHelper method inMemoryDefault.

/**
     * Creates new default datasource to in memory database
     * with url {@value #DEFAULT_IN_MEMORY_DB_URL}.
     * Boots database if this is invoked first time, database
     * won't be shutdown until 'SHUTDOWN' query is executed
     * or {@link #shutdownDefault()} is called directly.
     *
     * @return datasource to the in memory database
     * @deprecated use {@link H2DBTestServer}.
     */
@Deprecated
public static DataSource inMemoryDefault() {
    final JdbcDataSource dataSource = new JdbcDataSource();
    dataSource.setUrl(DEFAULT_IN_MEMORY_DB_URL);
    return dataSource;
}
Also used : JdbcDataSource(org.h2.jdbcx.JdbcDataSource)

Example 7 with JdbcDataSource

use of org.h2.jdbcx.JdbcDataSource in project aries by apache.

the class TransactionLogTest method setupServerAndDataSource.

private void setupServerAndDataSource() throws SQLException {
    server = Server.createTcpServer("-tcpPort", "0");
    server.start();
    File dbPath = new File("target/recovery-test/database");
    dataSource = new JdbcDataSource();
    dataSource.setUrl("jdbc:h2:tcp://127.0.0.1:" + server.getPort() + "/" + dbPath.getAbsolutePath());
}
Also used : JdbcDataSource(org.h2.jdbcx.JdbcDataSource) File(java.io.File)

Example 8 with JdbcDataSource

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;
}
Also used : JtaTransactionCoordinatorBuilderImpl(org.hibernate.resource.transaction.backend.jta.internal.JtaTransactionCoordinatorBuilderImpl) StandardServiceRegistryBuilder(org.hibernate.boot.registry.StandardServiceRegistryBuilder) DatasourceConnectionProviderImpl(org.hibernate.engine.jdbc.connections.internal.DatasourceConnectionProviderImpl) JdbcDataSource(org.h2.jdbcx.JdbcDataSource) BasicManagedDataSource(org.apache.commons.dbcp.managed.BasicManagedDataSource) Nullable(org.jetbrains.annotations.Nullable)

Example 9 with JdbcDataSource

use of org.h2.jdbcx.JdbcDataSource in project che by eclipse.

the class H2DBTestServer method start.

@Override
public void start() {
    final JdbcDataSource dataSource = new JdbcDataSource();
    dataSource.setUrl(getUrl() + ";DB_CLOSE_DELAY=-1");
    try (Connection conn = dataSource.getConnection()) {
        RunScript.execute(conn, new StringReader("SELECT 1"));
    } catch (SQLException x) {
        throw new RuntimeException(x);
    }
}
Also used : SQLException(java.sql.SQLException) JdbcDataSource(org.h2.jdbcx.JdbcDataSource) Connection(java.sql.Connection) StringReader(java.io.StringReader)

Example 10 with JdbcDataSource

use of org.h2.jdbcx.JdbcDataSource in project Activiti by Activiti.

the class MultiTenantProcessEngineTest method createDataSource.

// Helper //////////////////////////////////////////
private DataSource createDataSource(String jdbcUrl, String jdbcUsername, String jdbcPassword) {
    JdbcDataSource ds = new JdbcDataSource();
    ds.setURL(jdbcUrl);
    ds.setUser(jdbcUsername);
    ds.setPassword(jdbcPassword);
    return ds;
}
Also used : JdbcDataSource(org.h2.jdbcx.JdbcDataSource)

Aggregations

JdbcDataSource (org.h2.jdbcx.JdbcDataSource)12 Connection (java.sql.Connection)3 BeforeClass (org.junit.BeforeClass)2 NamingMixIn (org.switchyard.component.test.mixins.naming.NamingMixIn)2 File (java.io.File)1 StringReader (java.io.StringReader)1 SQLException (java.sql.SQLException)1 Statement (java.sql.Statement)1 InitialContext (javax.naming.InitialContext)1 BasicManagedDataSource (org.apache.commons.dbcp.managed.BasicManagedDataSource)1 StandardServiceRegistryBuilder (org.hibernate.boot.registry.StandardServiceRegistryBuilder)1 DatasourceConnectionProviderImpl (org.hibernate.engine.jdbc.connections.internal.DatasourceConnectionProviderImpl)1 JtaTransactionCoordinatorBuilderImpl (org.hibernate.resource.transaction.backend.jta.internal.JtaTransactionCoordinatorBuilderImpl)1 Nullable (org.jetbrains.annotations.Nullable)1 Ignore (org.junit.Ignore)1 Test (org.junit.Test)1 BeforeMethod (org.testng.annotations.BeforeMethod)1 Block (ratpack.func.Block)1 ExecHarness (ratpack.test.exec.ExecHarness)1