@Test public void testRunScript() throws Exception { JdbcScriptRunner runner = new JdbcScriptRunner(connection, true, true) .setErrorLogWriter(new PrintWriter(writer)) .setLogWriter(new PrintWriter(writer)); assertNotNull(runner); StringReader reader = new StringReader(scriptText); assertNotNull(reader); runner.runScript(reader); String text = writer.toString(); assertTrue(StringUtils.isNotBlank(text)); assertTrue(text.contains("CREATE TABLE PUBLIC.notes")); assertTrue(text.contains("INSERT INTO PUBLIC.notes (id, note) VALUES (1")); assertTrue(text.contains("SELECT id, note FROM notes")); }
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); } }
JdbcScriptRunner { 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); } } }
JdbcScriptRunner { 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); } } JdbcScriptRunner(Connection connection, boolean autoCommit,
                        boolean stopOnError); }
JdbcScriptRunner { 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); } } JdbcScriptRunner(Connection connection, boolean autoCommit,
                        boolean stopOnError); JdbcScriptRunner setDelimiter(String delimiter, boolean fullLineDelimiter); JdbcScriptRunner setLogWriter(PrintWriter logWriter); JdbcScriptRunner setErrorLogWriter(PrintWriter errorLogWriter); boolean isConsoleOut(); JdbcScriptRunner setConsoleOut(boolean consoleOut); void runScript(Reader reader); }
JdbcScriptRunner { 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); } } JdbcScriptRunner(Connection connection, boolean autoCommit,
                        boolean stopOnError); JdbcScriptRunner setDelimiter(String delimiter, boolean fullLineDelimiter); JdbcScriptRunner setLogWriter(PrintWriter logWriter); JdbcScriptRunner setErrorLogWriter(PrintWriter errorLogWriter); boolean isConsoleOut(); JdbcScriptRunner setConsoleOut(boolean consoleOut); void runScript(Reader reader);  }