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()); } }
@Test public void testPreCreateTableWillCreateSegmentsTable() throws MetaException { try (Handle handle = derbyConnectorRule.getConnector().getDBI().open()) { Assert.assertFalse(derbyConnectorRule.getConnector().tableExists(handle, segmentsTable)); druidStorageHandler.preCreateTable(tableMock); Assert.assertTrue(derbyConnectorRule.getConnector().tableExists(handle, segmentsTable)); } }
@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 testJustJdbiTransactions() throws Exception { Handle h1 = dbi.open(); Handle h2 = dbi.open(); h1.execute("insert into something (id, name) values (8, 'Mike')"); h1.begin(); h1.execute("update something set name = 'Miker' where id = 8"); assertEquals("Mike", h2.createQuery("select name from something where id = 8").map(StringMapper.FIRST).first()); h1.commit(); h1.close(); h2.close(); }
@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 testJustJdbiTransactions() throws Exception { Handle h1 = dbi.open(); Handle h2 = dbi.open(); h1.execute("insert into something (id, name) values (8, 'Mike')"); h1.begin(); h1.execute("update something set name = 'Miker' where id = 8"); assertEquals("Mike", h2.createQuery("select name from something where id = 8").mapTo(String.class).first()); h1.commit(); h1.close(); h2.close(); }
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))"); }
private void addColumn(Table table, String schema, String tableName, String columnName, FieldType fieldType) { List<TableColumn> existingColumns = dao.listTableColumns(schema, tableName); TableColumn lastColumn = existingColumns.get(existingColumns.size() - 1); long columnId = lastColumn.getColumnId() + 1; int ordinalPosition = existingColumns.size(); String type = TypeSignature.parseTypeSignature(toSql(fieldType)).toString().toLowerCase(ENGLISH); daoTransaction(dbi, MetadataDao.class, dao -> { dao.insertColumn(table.getTableId(), columnId, columnName, ordinalPosition, type, null, null); dao.updateTableVersion(table.getTableId(), System.currentTimeMillis()); }); String columnType = sqlColumnType(fieldType); if (columnType == null) { return; } String sql = format("ALTER TABLE %s ADD COLUMN (%s %s, %s %s)", shardIndexTable(table.getTableId()), minColumn(columnId), columnType, maxColumn(columnId), columnType); try (Handle handle = dbi.open()) { handle.execute(sql); } catch (DBIException e) { throw metadataError(e); } }
@Before public void setUp() throws Exception { DBI dbi = new DBI("jdbc:h2:mem:" + UUID.randomUUID()); handle = dbi.open(); handle.execute("create table something (id int primary key, name varchar(100))"); }
@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)"); }