use of com.torodb.core.exceptions.ToroRuntimeException in project torodb by torodb.
the class AbstractSchemaUpdater method executeSql.
@SuppressFBWarnings(value = "UI_INHERITANCE_UNSAFE_GETRESOURCE", justification = "We want to read resources from the subclass")
protected void executeSql(DSLContext dsl, String resourcePath, SqlHelper sqlHelper) {
try (InputStream resourceAsStream = getClass().getResourceAsStream(resourcePath)) {
if (resourceAsStream == null) {
throw new SystemException("Resource '" + resourcePath + "' does not exist");
}
String statementAsString = CharStreams.toString(new BufferedReader(new InputStreamReader(resourceAsStream, Charset.forName("UTF-8"))));
sqlHelper.executeStatement(dsl, statementAsString, Context.UNKNOWN);
} catch (IOException ex) {
throw new ToroRuntimeException(ex);
}
}
Aggregations