Example usage for org.hibernate.tool.hbm2ddl ImportScriptException ImportScriptException

List of usage examples for org.hibernate.tool.hbm2ddl ImportScriptException ImportScriptException

Introduction

In this page you can find the example usage for org.hibernate.tool.hbm2ddl ImportScriptException ImportScriptException.

Prototype

public ImportScriptException(String string, Throwable root) 

Source Link

Usage

From source file:org.jboss.ci.tracker.server.CustomMultipleLinesSqlCommandExtractor.java

License:Open Source License

@Override
public String[] extractCommands(Reader reader) {
    BufferedReader bufferedReader = new BufferedReader(reader);
    List<String> statementList = new ArrayList<String>();

    try {//from w ww  .ja  v  a  2s. com
        String statement = "";
        for (String sql = bufferedReader.readLine(); sql != null; sql = bufferedReader.readLine()) {
            String trimmedSql = sql.trim();

            if (StringHelper.isEmpty(trimmedSql) || isComment(trimmedSql)) {
                continue;
            }

            if (trimmedSql.endsWith("^")) {
                trimmedSql = trimmedSql.substring(0, trimmedSql.length() - 1);
                statement += " " + trimmedSql;
                statementList.add(statement);
                statement = "";
            } else {
                statement += " " + trimmedSql;
            }
        }

        return statementList.toArray(new String[statementList.size()]);
    } catch (IOException e) {
        throw new ImportScriptException("Error during import script parsing.", e);
    }
}