use of org.h2.jdbcx.JdbcDataSource in project h2database by h2database.
the class TestXA method testRollbackWithoutPrepare.
private void testRollbackWithoutPrepare() throws Exception {
if (config.memory) {
return;
}
Xid xid = new Xid() {
@Override
public int getFormatId() {
return 3145;
}
@Override
public byte[] getGlobalTransactionId() {
return new byte[] { 1, 2, 3, 4, 5, 6, 6, 7, 8 };
}
@Override
public byte[] getBranchQualifier() {
return new byte[] { 34, 43, 33, 3, 3, 3, 33, 33, 3 };
}
};
deleteDb("xa");
JdbcDataSource ds = new JdbcDataSource();
ds.setURL(getURL("xa", true));
ds.setPassword(getPassword());
Connection dm = ds.getConnection();
Statement stat = dm.createStatement();
stat.execute("CREATE TABLE IF NOT EXISTS TEST(ID INT PRIMARY KEY, VAL INT)");
stat.execute("INSERT INTO TEST(ID,VAL) VALUES (1,1)");
dm.close();
XAConnection c = ds.getXAConnection();
XAResource xa = c.getXAResource();
Connection connection = c.getConnection();
xa.start(xid, XAResource.TMJOIN);
PreparedStatement ps = connection.prepareStatement("UPDATE TEST SET VAL=? WHERE ID=?");
ps.setInt(1, new Random().nextInt());
ps.setInt(2, 1);
ps.close();
xa.rollback(xid);
connection.close();
c.close();
deleteDb("xa");
}
use of org.h2.jdbcx.JdbcDataSource in project jdbi by jdbi.
the class TestMixinInterfaces method setUp.
@Before
public void setUp() throws Exception {
JdbcDataSource ds = new JdbcDataSource();
ds.setURL(String.format("jdbc:h2:mem:%s;MVCC=TRUE", UUID.randomUUID()));
db = Jdbi.create(ds);
db.installPlugin(new SqlObjectPlugin());
handle = db.open();
handle.execute("create table something (id int primary key, name varchar(100))");
}
use of org.h2.jdbcx.JdbcDataSource in project jdbi by jdbi.
the class TestOnDemandObjectMethodBehavior method setUp.
@Before
public void setUp() throws Exception {
final JdbcDataSource ds = new JdbcDataSource() {
private static final long serialVersionUID = 1L;
@Override
public Connection getConnection() throws SQLException {
throw new UnsupportedOperationException();
}
};
db = Jdbi.create(ds);
db.installPlugin(new SqlObjectPlugin());
dao = db.onDemand(UselessDao.class);
}
use of org.h2.jdbcx.JdbcDataSource in project tutorials by eugenp.
the class PersistenceContextIntegrationTest method dataSource.
@Bean
public DataSource dataSource() {
JdbcDataSource dataSource = new JdbcDataSource();
dataSource.setUrl(environment.getRequiredProperty("db.url"));
dataSource.setUser(environment.getRequiredProperty("db.username"));
dataSource.setPassword(environment.getRequiredProperty("db.password"));
return dataSource;
}
use of org.h2.jdbcx.JdbcDataSource in project microservice_framework by CJSCommonPlatform.
the class AbstractJdbcRepositoryIT method registerDataSource.
protected void registerDataSource() throws Exception {
System.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.apache.naming.java.javaURLContextFactory");
System.setProperty(Context.URL_PKG_PREFIXES, "org.apache.naming");
dataSource = new JdbcDataSource();
dataSource.setURL("jdbc:h2:mem:test;MV_STORE=FALSE;MVCC=FALSE");
dataSource.setUser("sa");
dataSource.setPassword("sa");
setField(jdbcRepository, "datasource", dataSource);
initDatabase();
}
Aggregations