@SuppressWarnings("PMD.EmptyCatchBlock") public void destroy() { try { dbi.useHandle(h -> h.execute("DROP TABLE filestore")); } catch (CallbackFailedException ex) { // simply ignore } }
@SuppressWarnings("PMD.EmptyCatchBlock") public void destroy() { try { dbi.useHandle(h -> h.execute("DROP TABLE filestore")); } catch (CallbackFailedException ex) { // simply ignore } }
@SuppressWarnings("PMD.EmptyCatchBlock") public void destroy() { try { dbi.useHandle(h -> h.execute("DROP TABLE filestore")); } catch (CallbackFailedException ex) { // simply ignore } }
@SuppressWarnings("PMD.EmptyCatchBlock") public void destroy() { try { dbi.useHandle(h -> h.execute("DROP TABLE icon_filestore")); } catch (CallbackFailedException ex) { // simply ignore } }
@Test public void testUseHandle() throws Exception { DBI dbi = new DBI(DERBY_HELPER.getDataSource()); dbi.useHandle(new HandleConsumer() { @Override public void useHandle(Handle handle) throws Exception { handle.insert("insert into something (id, name) values (1, 'Brian')"); String value = handle.createQuery("select name from something where id = 1").map(Something.class).first().getName(); assertEquals("Brian", value); } }); } }
public void init() { boolean needsInitialization = !dbi.inTransaction((h, s) -> tableExists(h, "filestore")); if (needsInitialization) { try { dbi.useHandle(h -> { if (databaseKind == DatabaseKind.PostgreSQL) { h.execute("CREATE TABLE filestore (path VARCHAR COLLATE \"C\" PRIMARY KEY, data OID)"); } else if (databaseKind == DatabaseKind.H2) { h.execute("CREATE TABLE filestore (path VARCHAR PRIMARY KEY, data BLOB)"); } else if (databaseKind == DatabaseKind.Apache_Derby) { h.execute("CREATE TABLE filestore (path VARCHAR(1000), data BLOB, PRIMARY KEY (path))"); } else { throw new DaoException("Unsupported database kind: " + databaseKind); } }); } catch (CallbackFailedException ex) { throw new DaoException("Unable to initialize the filestore", ex); } } }
@Override public void init() { boolean needsInitialization = !dbi.inTransaction((h, s) -> tableExists(h, "icon_filestore")); if (needsInitialization) { try { dbi.useHandle(h -> { if (databaseKind == DatabaseKind.PostgreSQL) { h.execute("CREATE TABLE icon_filestore (id VARCHAR COLLATE \"C\" PRIMARY KEY, data OID)"); } else if (databaseKind == DatabaseKind.H2) { h.execute("CREATE TABLE icon_filestore (id VARCHAR PRIMARY KEY, data BLOB)"); } else if (databaseKind == DatabaseKind.Apache_Derby) { h.execute("CREATE TABLE icon_filestore (id VARCHAR(1000), data BLOB, PRIMARY KEY (path))"); } else { throw new IconDataAccessException("Unsupported database kind: " + databaseKind); } }); } catch (CallbackFailedException ex) { throw new IconDataAccessException("Unable to initialize the icon_filestore", ex); } } }
public void init() { boolean needsInitialization = !dbi.inTransaction((h, s) -> tableExists(h, "filestore")); if (needsInitialization) { try { dbi.useHandle(h -> { if (databaseKind == DatabaseKind.PostgreSQL) { h.execute("CREATE TABLE filestore (path VARCHAR COLLATE \"C\" PRIMARY KEY, data OID)"); } else if (databaseKind == DatabaseKind.H2) { h.execute("CREATE TABLE filestore (path VARCHAR PRIMARY KEY, data BLOB)"); } else if (databaseKind == DatabaseKind.Apache_Derby) { h.execute("CREATE TABLE filestore (path VARCHAR(1000), data BLOB, PRIMARY KEY (path))"); } else { throw new DaoException("Unsupported database kind: " + databaseKind); } }); } catch (CallbackFailedException ex) { throw new DaoException("Unable to initialize the filestore", ex); } } }
@Override public void init() { boolean needsInitialization = !dbi.inTransaction((h, s) -> tableExists(h, "filestore")); if (needsInitialization) { try { dbi.useHandle(h -> { if (databaseKind == DatabaseKind.PostgreSQL) { h.execute("CREATE TABLE filestore (path VARCHAR COLLATE \"C\" PRIMARY KEY, data OID)"); } else if (databaseKind == DatabaseKind.H2) { h.execute("CREATE TABLE filestore (path VARCHAR PRIMARY KEY, data BLOB)"); } else if (databaseKind == DatabaseKind.Apache_Derby) { h.execute("CREATE TABLE filestore (path VARCHAR(1000), data BLOB, PRIMARY KEY (path))"); } else { throw new ExtensionDataAccessException("Unsupported database kind: " + databaseKind); } }); } catch (CallbackFailedException ex) { throw new ExtensionDataAccessException("Unable to initialize the filestore", ex); } } }