Search in sources :

Example 31 with JdbcDataSource

use of org.h2.jdbcx.JdbcDataSource in project ma-core-public by infiniteautomation.

the class H2Proxy method initializeImpl.

@Override
protected void initializeImpl(String propertyPrefix) {
    LOG.info("Initializing H2 connection manager");
    JdbcDataSource jds = new JdbcDataSource();
    jds.setURL(getUrl(propertyPrefix));
    jds.setDescription("maDataSource");
    String user = Common.envProps.getString(propertyPrefix + "db.username", null);
    if (user != null) {
        jds.setUser(user);
        String password = Common.envProps.getString(propertyPrefix + "db.password", null);
        if (password != null)
            jds.setPassword(password);
    }
    dataSource = JdbcConnectionPool.create(jds);
    dataSource.setMaxConnections(Common.envProps.getInt(propertyPrefix + "db.pool.maxActive", 100));
    if (Common.envProps.getBoolean(propertyPrefix + "db.web.start", false)) {
        LOG.info("Initializing H2 web server");
        String[] webArgs = new String[4];
        webArgs[0] = "-webPort";
        webArgs[1] = Common.envProps.getString(propertyPrefix + "db.web.port");
        webArgs[2] = "-ifExists";
        webArgs[3] = "-webAllowOthers";
        try {
            this.web = Server.createWebServer(webArgs);
            this.web.start();
        } catch (SQLException e) {
            LOG.error(e);
        }
    }
}
Also used : SQLException(java.sql.SQLException) JdbcDataSource(org.h2.jdbcx.JdbcDataSource)

Example 32 with JdbcDataSource

use of org.h2.jdbcx.JdbcDataSource in project syndesis by syndesisio.

the class JsonDBTest method before.

@Before
public void before() {
    JdbcDataSource ds = new JdbcDataSource();
    ds.setURL("jdbc:h2:mem:test1;DB_CLOSE_DELAY=-1;MODE=PostgreSQL");
    DBI dbi = new DBI(ds);
    this.jsondb = new SqlJsonDB(dbi, null, Arrays.asList(new Index("/pair", "key"), new Index("/users", "name"), new Index("/users", "age")));
    try {
        this.jsondb.dropTables();
    } catch (Exception e) {
    }
    this.jsondb.createTables();
}
Also used : JdbcDataSource(org.h2.jdbcx.JdbcDataSource) DBI(org.skife.jdbi.v2.DBI) JsonDBException(io.syndesis.server.jsondb.JsonDBException) IOException(java.io.IOException) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) Before(org.junit.Before)

Example 33 with JdbcDataSource

use of org.h2.jdbcx.JdbcDataSource in project sandbox by irof.

the class FirstTest method setup.

@Before
public void setup() throws Exception {
    // H2DatabaseのDataSourceを用意
    dataSource = new JdbcDataSource();
    dataSource.setURL("jdbc:h2:mem:temp;DB_CLOSE_DELAY=-1");
    dataSource.setUser("sa");
    // Flywayでテーブル作成
    Flyway flyway = new Flyway();
    flyway.setDataSource(dataSource);
    flyway.migrate();
}
Also used : Flyway(org.flywaydb.core.Flyway) JdbcDataSource(org.h2.jdbcx.JdbcDataSource) Before(org.junit.Before)

Example 34 with JdbcDataSource

use of org.h2.jdbcx.JdbcDataSource in project quickstarts by jboss-switchyard.

the class CamelJpaBindingTest method beforeClass.

@BeforeClass
public static void beforeClass() throws Exception {
    namingMixIn = new NamingMixIn();
    namingMixIn.initialize();
    connection = DriverManager.getConnection("jdbc:h2:mem:events-jpa-quickstart", "sa", "sa");
    JdbcDataSource ds = new JdbcDataSource();
    ds.setURL("jdbc:h2:mem:events-jpa-quickstart");
    ds.setUser("sa");
    ds.setPassword("sa");
    InitialContext initialContext = new InitialContext();
    bind(initialContext, System.getProperty("jpa.persistence.datasource.name"), ds);
}
Also used : JdbcDataSource(org.h2.jdbcx.JdbcDataSource) NamingMixIn(org.switchyard.component.test.mixins.naming.NamingMixIn) InitialContext(javax.naming.InitialContext) BeforeClass(org.junit.BeforeClass)

Example 35 with JdbcDataSource

use of org.h2.jdbcx.JdbcDataSource in project quickstarts by jboss-switchyard.

the class CamelSqlBindingTest method startUp.

@BeforeClass
public static void startUp() throws Exception {
    dataSource = new JdbcDataSource();
    dataSource.setURL("jdbc:h2:mem:test");
    dataSource.setUser("sa");
    dataSource.setPassword("sa");
    connection = dataSource.getConnection();
    String createStatement = "CREATE TABLE greetings (" + "id INT PRIMARY KEY AUTO_INCREMENT, " + "receiver VARCHAR(255), " + "sender VARCHAR(255) " + ");";
    connection.createStatement().executeUpdate("DROP TABLE IF EXISTS greetings");
    connection.createStatement().executeUpdate(createStatement);
    namingMixIn = new NamingMixIn();
    namingMixIn.initialize();
    bindDataSource(namingMixIn.getInitialContext(), "java:jboss/myDS", dataSource);
}
Also used : JdbcDataSource(org.h2.jdbcx.JdbcDataSource) NamingMixIn(org.switchyard.component.test.mixins.naming.NamingMixIn) BeforeClass(org.junit.BeforeClass)

Aggregations

JdbcDataSource (org.h2.jdbcx.JdbcDataSource)81 Connection (java.sql.Connection)24 Test (org.junit.Test)24 Before (org.junit.Before)15 XAResource (javax.transaction.xa.XAResource)13 DataSource (javax.sql.DataSource)9 Xid (javax.transaction.xa.Xid)9 SQLException (java.sql.SQLException)8 InitialContext (javax.naming.InitialContext)8 XAConnection (javax.sql.XAConnection)8 RecoveryModule (com.arjuna.ats.arjuna.recovery.RecoveryModule)7 CommitMarkableResourceRecordRecoveryModule (com.arjuna.ats.internal.jta.recovery.arjunacore.CommitMarkableResourceRecordRecoveryModule)7 XARecoveryModule (com.arjuna.ats.internal.jta.recovery.arjunacore.XARecoveryModule)7 XAResourceRecoveryHelper (com.arjuna.ats.jta.recovery.XAResourceRecoveryHelper)7 Statement (java.sql.Statement)7 BMScript (org.jboss.byteman.contrib.bmunit.BMScript)7 File (java.io.File)6 Enumeration (java.util.Enumeration)6 Properties (java.util.Properties)6 Vector (java.util.Vector)6