private static void runScript(Connection conn, Reader reader, String filename, boolean verbosity) { ScriptRunner runner = new ScriptRunner(conn, false, true, verbosity); try { runner.runScript(reader); } catch (IOException e) { System.err.println("Unable to read " + filename + ": " + e.getMessage()); System.exit(1); } catch (SQLException e) { System.err.println("Unable to execute " + filename + ": " + e.getMessage()); System.exit(1); } }
println(trimmedLine); } else if (trimmedLine.length() < 1 || trimmedLine.startsWith("//")) { } else if (!fullLineDelimiter && trimmedLine.endsWith(getDelimiter()) || fullLineDelimiter && trimmedLine.equals(getDelimiter())) { command.append(line.substring(0, line.lastIndexOf(getDelimiter()))); command.append(" "); try (Statement statement = conn.createStatement();) { println(command); boolean hasResults = false; if (stopOnError) { } catch (SQLException e) { e.fillInStackTrace(); printlnError("Error executing: " + command); printlnError(e); for (int i = 0; i < cols; i++) { String name = md.getColumnLabel(i); print(name + "\t"); println(""); while (rs.next()) { for (int i = 1; i <= cols; i++) { String value = rs.getString(i); print(value + "\t"); println(""); printlnError("Error executing: " + command);
/** * Runs an SQL script (read in using the Reader parameter) * * @param reader * - the source of the script */ public void runScript(Reader reader) throws IOException, SQLException { try { boolean originalAutoCommit = connection.getAutoCommit(); try { if (originalAutoCommit != this.autoCommit) { connection.setAutoCommit(this.autoCommit); } runScript(connection, reader); } finally { connection.setAutoCommit(originalAutoCommit); } } catch (IOException e) { throw e; } catch (SQLException e) { throw e; } catch (Exception e) { throw new RuntimeException("Error running script. Cause: " + e, e); } }
/** * Runs an SQL script (read in using the Reader parameter) * * @param reader - the source of the script */ public void runScript(Reader reader) throws IOException, SQLException { try { boolean originalAutoCommit = connection.getAutoCommit(); try { if (originalAutoCommit != this.autoCommit) { connection.setAutoCommit(this.autoCommit); } runScript(connection, reader); } finally { connection.setAutoCommit(originalAutoCommit); } } catch (IOException e) { throw e; } catch (SQLException e) { throw e; } catch (Exception e) { throw new RuntimeException("Error running script. Cause: " + e, e); } }
println(trimmedLine); } else if (trimmedLine.length() < 1 || trimmedLine.startsWith("//")) { } else if (!fullLineDelimiter && trimmedLine.endsWith(getDelimiter()) || fullLineDelimiter && trimmedLine.equals(getDelimiter())) { command.append(line.substring(0, line.lastIndexOf(getDelimiter()))); command.append(" "); try (Statement statement = conn.createStatement();) { println(command); boolean hasResults = false; if (stopOnError) { } catch (SQLException e) { e.fillInStackTrace(); printlnError("Error executing: " + command); printlnError(e); for (int i = 0; i < cols; i++) { String name = md.getColumnLabel(i); print(name + "\t"); println(""); while (rs.next()) { for (int i = 1; i <= cols; i++) { String value = rs.getString(i); print(value + "\t"); println(""); printlnError("Error executing: " + command);
protected void runScript(Connection conn, InputStream file) { try (InputStreamReader reader = new InputStreamReader(file)) { ScriptRunner runner = new ScriptRunner(conn, false, true); runner.runScript(reader); } catch (IOException e) { s_logger.error("Unable to read upgrade script", e); throw new CloudRuntimeException("Unable to read upgrade script", e); } catch (SQLException e) { s_logger.error("Unable to execute upgrade script", e); throw new CloudRuntimeException("Unable to execute upgrade script", e); } }
ScriptRunner runner = new ScriptRunner(conn, false, true); runner.runScript(reader); } catch (SQLException | IOException e) { s_logger.error("Unable to insert default api-role mappings from file: " + script + ". Please configure api per role manually, giving up!", e);