@Override protected void createIndexes() throws SQLException { try { ScriptRunner runner = new ScriptRunner(connection.getJDBCConnection(), false, false); StringBuilder script = new StringBuilder(); for(String line : IOUtils.readLines(KiWiPostgresHandler.class.getResourceAsStream("create_indexes.sql"))) { if(!line.startsWith("--")) { script.append(line); script.append(" "); } } log.debug("PostgreSQL: running SQL script '{}'", script.toString()); runner.runScript(new StringReader(script.toString())); } catch (IOException ex) { throw new SQLException("error while creating indexes",ex); } }
println(trimmedLine); } else if (trimmedLine.length() < 1 || trimmedLine.startsWith("//")) { } else if (!fullLineDelimiter && trimmedLine.endsWith(getDelimiter()) || fullLineDelimiter && trimmedLine.equals(getDelimiter())) { setDelimiter(trimmedLine.split(DELIMITER_LINE_SPLIT_REGEX)[1].trim(), fullLineDelimiter); line = lineReader.readLine(); command.append(line.substring(0, line.lastIndexOf(getDelimiter()))); command.append(" "); Statement statement = conn.createStatement(); println(command); } 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);
/** /** * Runs an SQL script (read in using the Reader parameter). * * @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 */ public void runScript(Reader reader) throws IOException, SQLException { try { boolean originalAutoCommit = connection.getAutoCommit(); try { if (originalAutoCommit != autoCommit) { connection.setAutoCommit(autoCommit); } runScript(connection, reader); } finally { connection.setAutoCommit(originalAutoCommit); } } catch (IOException | 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())) { setDelimiter(trimmedLine.split(DELIMITER_LINE_SPLIT_REGEX)[1].trim(), fullLineDelimiter); line = lineReader.readLine(); command.append(line.substring(0, line.lastIndexOf(getDelimiter()))); command.append(" "); Statement statement = conn.createStatement(); println(command); } 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);
/** /** * Runs an SQL script (read in using the Reader parameter). * * @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 */ public void runScript(Reader reader) throws IOException, SQLException { try { boolean originalAutoCommit = connection.getAutoCommit(); try { if (originalAutoCommit != autoCommit) { connection.setAutoCommit(autoCommit); } runScript(connection, reader); } finally { connection.setAutoCommit(originalAutoCommit); } } catch (IOException | SQLException e) { throw e; } catch (Exception e) { throw new RuntimeException("Error running script. Cause: " + e, e); } }
@Override protected void dropIndexes() throws SQLException { try { ScriptRunner runner = new ScriptRunner(connection.getJDBCConnection(), false, false); StringBuilder script = new StringBuilder(); for(String line : IOUtils.readLines(KiWiPostgresHandler.class.getResourceAsStream("drop_indexes.sql"))) { if(!line.startsWith("--")) { script.append(line); script.append(" "); } } log.debug("PostgreSQL: running SQL script '{}'", script.toString()); runner.runScript(new StringReader(script.toString())); } catch (IOException ex) { throw new SQLException("error while dropping indexes",ex); } }
@Override protected void dropIndexes() throws SQLException { try { ScriptRunner runner = new ScriptRunner(connection.getJDBCConnection(), false, false); StringBuilder script = new StringBuilder(); for(String line : IOUtils.readLines(KiWiPostgresHandler.class.getResourceAsStream("drop_indexes.sql"))) { if(!line.startsWith("--")) { script.append(line); script.append(" "); } } log.debug("PostgreSQL: running SQL script '{}'", script.toString()); runner.runScript(new StringReader(script.toString())); } catch (IOException ex) { throw new SQLException("error while dropping indexes",ex); } }
@Override protected void createIndexes() throws SQLException { try { ScriptRunner runner = new ScriptRunner(connection.getJDBCConnection(), false, false); StringBuilder script = new StringBuilder(); for(String line : IOUtils.readLines(KiWiPostgresHandler.class.getResourceAsStream("create_indexes.sql"))) { if(!line.startsWith("--")) { script.append(line); script.append(" "); } } log.debug("PostgreSQL: running SQL script '{}'", script.toString()); runner.runScript(new StringReader(script.toString())); } catch (IOException ex) { throw new SQLException("error while creating indexes",ex); } }
ScriptRunner runner = new ScriptRunner(connection.getJDBCConnection(), false, false); if (connection.getMetadata("ft.lookup") == null) { log.info("PostgreSQL: creating language configuration lookup function"); runner.runScript(new StringReader(script.toString())); String script_lang = script.toString().replaceAll("@LANGUAGE@", lang).replaceAll("@CONFIGURATION@", pg_configuration); log.debug("PostgreSQL: running SQL script '{}'", script_lang); runner.runScript(new StringReader(script_lang)); runner.runScript(new StringReader(script.toString()));
log.info("creating new KiWi database ..."); ScriptRunner runner = new ScriptRunner(connection.getJDBCConnection(), false, false); runner.runScript(new StringReader(configuration.getDialect().getCreateScript(scriptName))); log.info("upgrading existing KiWi database from version {} to version {}", version, configuration.getDialect().getVersion()); ScriptRunner runner = new ScriptRunner(connection.getJDBCConnection(), false, false); runner.runScript(new StringReader(updateScript));
log.info("creating new KiWi database ..."); ScriptRunner runner = new ScriptRunner(connection.getJDBCConnection(), false, false); runner.runScript(new StringReader(configuration.getDialect().getCreateScript(scriptName))); log.info("upgrading existing KiWi database from version {} to version {}", version, configuration.getDialect().getVersion()); ScriptRunner runner = new ScriptRunner(connection.getJDBCConnection(), false, false); runner.runScript(new StringReader(updateScript));
ScriptRunner runner = new ScriptRunner(connection.getJDBCConnection(), false, false); runner.runScript(new StringReader(configuration.getDialect().getDropScript(scriptName)));
ScriptRunner runner = new ScriptRunner(connection.getJDBCConnection(), false, false); runner.runScript(new StringReader(configuration.getDialect().getDropScript(scriptName)));