code: private void runScript(Connection conn, Reader reader) throws IOException,
              SQLException {
          StringBuffer command = null;
          try {
              LineNumberReader lineReader = new LineNumberReader(reader);
              String line;
              while ((line = lineReader.readLine()) != null) {
                  if (command == null) {
                      command = new StringBuffer();
                  }
                  String trimmedLine = line.trim();
                  final Matcher delimMatch = delimP.matcher(trimmedLine);
                  if (trimmedLine.length() < 1
                          || trimmedLine.startsWith("//")) {
                      // Do nothing
                  } else if (delimMatch.matches()) {
                      setDelimiter(delimMatch.group(2), false);
                  } else if (trimmedLine.startsWith("--")) {
                      logger.debug(trimmedLine);
                  } else if (trimmedLine.length() < 1
                          || trimmedLine.startsWith("--")) {
                      // Do nothing
                  } else if (!fullLineDelimiter
                          && trimmedLine.endsWith(getDelimiter())
                          || fullLineDelimiter
                          && trimmedLine.equals(getDelimiter())) {
                      command.append(line.substring(0, line
                              .lastIndexOf(getDelimiter())));
                      command.append(" ");
                      this.execCommand(conn, command, lineReader);
                      command = null;
                  } else {
                      command.append(line);
                      command.append("\n");
                  }
              }
              if (command != null && command.length() > 0) {
                  this.execCommand(conn, command, lineReader);
              }
              if (!autoCommit) {
                  conn.commit();
              }
          }
          catch (IOException e) {
              throw new IOException(String.format("Error executing '%s': %s", command, e.getMessage()), e);
          } finally {
              conn.rollback();
          }
      }
docs: Runs an SQL script (read in using the Reader parameter) using the
  connection passed in
  
  @param conn - the connection to use for the script
  @param reader - the source of the script
  @throws SQLException if any SQL errors occur
  @throws IOException if there is an error reading from the Reader