Refine search
public void tearDown() { try { new DBI(jdbcUri + ";drop=true").open().close(); } catch (UnableToObtainConnectionException e) { SQLException cause = (SQLException) e.getCause(); // error code "08006" indicates proper shutdown Assert.assertEquals(StringUtils.format("Derby not shutdown: [%s]", cause.toString()), "08006", cause.getSQLState()); } }
@Before public void setUp() throws Exception { this.dbi = new DBI("jdbc:h2:mem:" + UUID.randomUUID()); this.h = dbi.open(); h.execute("create table something (id int primary key, name varchar)"); }
@Before public void setUp() throws Exception { dbi = new DBI("jdbc:hsqldb:mem:" + UUID.randomUUID(), "username", "password"); dbi.withHandle(new HandleCallback<Object>() { @Override public Object withHandle(Handle handle) throws Exception { handle.execute("create table something (id identity primary key, name varchar(32))"); return null; } }); }
@Test public void testObtainHandleViaOpen() throws Exception { DBI dbi = new DBI("jdbc:h2:mem:" + UUID.randomUUID()); Handle handle = dbi.open(); // make sure to close it! handle.close(); }
@Before public void setUp() throws Exception { dbi = new DBI("jdbc:oracle:thin:@localhost:test", "oracle", "oracle"); dbi.withHandle(new HandleCallback<Object>() { public Object withHandle(Handle handle) throws Exception { handle.execute("create sequence something_id_sequence INCREMENT BY 1 START WITH 100"); handle.execute("create table something (name varchar(200), id int, constraint something_id primary key (id))"); return null; } }); }
@BeforeClass public static void init() { assumeTrue(Boolean.parseBoolean(System.getenv("TRAVIS"))); handle = new DBI("jdbc:postgresql:jdbi_test", "postgres", "").open(); handle.execute("create table something (id int primary key, name varchar(100))"); handle.execute("insert into something(id, name) values(1, null)"); handle.execute("insert into something(id, name) values(2, 'bla')"); handle.execute("insert into something(id, name) values(3, 'null')"); handle.execute("insert into something(id, name) values(4, '')"); }
@Before public void setUp() throws Exception { dbi = new DBI("jdbc:h2:mem:" + UUID.randomUUID()); handle = dbi.open(); handle.execute("create table something( id integer primary key, name varchar(100) )"); }
@Test public void testObtainHandleViaOpen() throws Exception { DBI dbi = new DBI("jdbc:h2:mem:" + UUID.randomUUID()); Handle handle = dbi.open(); // make sure to close it! handle.close(); }
@Before public void setUp() throws Exception { dbi = new DBI("jdbc:postgresql:jdbi_test", "postgres", ""); dbi.withHandle(new HandleCallback<Object>() { @Override public Object withHandle(Handle handle) throws Exception { handle.execute("CREATE FUNCTION set100(OUT outparam INT) AS $$ BEGIN outparam \\:= 100; END; $$ LANGUAGE plpgsql"); return null; } }); }
public void tearDown() { try { new DBI(jdbcUri + ";drop=true").open().close(); } catch (UnableToObtainConnectionException e) { SQLException cause = (SQLException) e.getCause(); // error code "08006" indicates proper shutdown Assert.assertEquals(String.format("Derby not shutdown: [%s]", cause.toString()), "08006", cause.getSQLState() ); } }
@Before public void setUp() throws Exception { dbi = new DBI("jdbc:h2:mem:" + UUID.randomUUID()); handle = dbi.open(); handle.execute("create table something (id int primary key, name varchar(100))"); }
@Test public void testAttachToObject() throws Exception { DBI dbi = new DBI("jdbc:h2:mem:" + UUID.randomUUID()); Handle h = dbi.open(); MyDAO dao = h.attach(MyDAO.class); // do stuff with the dao h.close(); }
@Before public void setUp() throws Exception { dbi = new DBI("jdbc:postgresql:jdbi_test", "postgres", ""); dbi.withHandle(new HandleCallback<Object>() { @Override public Object withHandle(Handle handle) throws Exception { handle.execute("create sequence id_sequence INCREMENT 1 START WITH 100"); handle.execute("create table if not exists something (name text, id int DEFAULT nextval('id_sequence'), CONSTRAINT something_id PRIMARY KEY ( id ));"); return null; } }); }
@Before public void setUp() throws Exception { dbi = new DBI("jdbc:h2:mem:" + UUID.randomUUID()); handle = dbi.open(); handle.execute("create table something (id int primary key, name varchar(100))"); }
@Test public void testAttachToObject() throws Exception { DBI dbi = new DBI("jdbc:h2:mem:" + UUID.randomUUID()); Handle h = dbi.open(); MyDAO dao = h.attach(MyDAO.class); // do stuff with the dao h.close(); }
@Before public void setUp() throws Exception { dbi = new DBI("jdbc:postgresql:test", "postgres", "postgres"); dbi.withHandle(new HandleCallback<Object>() { @Override public Object withHandle(Handle handle) throws Exception { handle.execute("create sequence id_sequence INCREMENT 1 START WITH 100"); handle.execute("create table if not exists something (name text, id int DEFAULT nextval('id_sequence'), CONSTRAINT something_id PRIMARY KEY ( id ));"); return null; } }); }