private static void showHelp(final String helpResource) { if (sf.util.Utility.isBlank(helpResource) || SchemaCrawlerHelpCommandLine.class.getResource(helpResource) == null) { return; } final String helpText = Utility.readResourceFully(helpResource); System.out.println(helpText); }
private static void showHelp(final String helpResource) { final String helpResourceName; if (sf.util.Utility.isBlank(helpResource) || SchemaCrawlerHelpCommandLine.class.getResource(helpResource) == null) { helpResourceName = "/help/DefaultExecutable.txt"; } else { helpResourceName = helpResource; } final String helpText = Utility.readResourceFully(helpResourceName); System.out.println(helpText); }
/** * Setup the schema. * * @param dataSource Datasource * @param schemas Schema names */ private static void setupSchema( final DatabaseConnectionOptions dataSource, final String... schemas) { Connection connection = null; Statement statement = null; try { if (dataSource != null) { connection = dataSource.getConnection(); connection.setAutoCommit(true); statement = connection.createStatement(); for (final String schema : schemas) { for (final String scriptType : new String[] { "pre_schema", "schema", "post_schema", "data", }) { final String scriptResource = String.format("/testdatabase/%s.%s.sql", schema, scriptType) .toLowerCase(Locale.ENGLISH); final String sqlScript = Utility.readResourceFully(scriptResource); if (!Utility.isBlank(sqlScript)) { for (final String sql : sqlScript.split(";")) { if (!Utility.isBlank(sql)) { statement.executeUpdate(sql); } } } } } connection.close(); } } catch (final SQLException e) { System.err.println(e.getMessage()); LOGGER.log(Level.WARNING, e.getMessage(), e); } finally { if (statement != null) { try { statement.close(); } catch (final SQLException e) { LOGGER.log(Level.WARNING, "", e); } } if (connection != null) { try { connection.close(); } catch (final SQLException e) { LOGGER.log(Level.WARNING, "", e); } } } }
static { ABOUT = Utility.readResourceFully("/help/SchemaCrawler.txt"); String[] productLine; try { final String readLine = new BufferedReader(new StringReader(ABOUT)).readLine(); if (readLine != null) { productLine = readLine.split(" "); } else { productLine = new String[] {PRODUCTNAME, ""}; } } catch (final IOException e) { productLine = new String[] {PRODUCTNAME, ""}; } VERSION = productLine[1]; }