Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import static us.fatehi.commandlineparser.CommandLineUtility.applyApplicationLogLevel;
- import static us.fatehi.commandlineparser.CommandLineUtility.logSystemProperties;
- import java.sql.Connection;
- import java.sql.SQLException;
- import java.util.Collection;
- import java.util.Iterator;
- import java.util.logging.Level;
- import javax.sql.DataSource;
- import schemacrawler.schema.Catalog;
- import schemacrawler.schema.Column;
- import schemacrawler.schema.JavaSqlType;
- import schemacrawler.schema.Schema;
- import schemacrawler.schema.Table;
- import schemacrawler.schemacrawler.DatabaseConnectionOptions;
- import schemacrawler.schemacrawler.ExcludeAll;
- import schemacrawler.schemacrawler.RegularExpressionInclusionRule;
- import schemacrawler.schemacrawler.SchemaCrawlerException;
- import schemacrawler.schemacrawler.SchemaCrawlerOptions;
- import schemacrawler.tools.options.InfoLevel;
- import schemacrawler.utility.SchemaCrawlerUtility;
- public final class Issue167
- {
- public static void main(final String[] args)
- throws Exception
- {
- // Turn application logging on by applying the correct log level
- applyApplicationLogLevel(Level.OFF);
- // Log system properties and classpath
- logSystemProperties();
- final Connection connection = getConnection();
- final SchemaCrawlerOptions sco = new SchemaCrawlerOptions();
- sco.setSchemaInfoLevel(InfoLevel.standard.buildSchemaInfoLevel());
- sco.setRoutineInclusionRule(new ExcludeAll());
- sco
- .setSchemaInclusionRule(new RegularExpressionInclusionRule("SVIL"));
- sco.setTableNamePattern("XGPI_DDL_ORACLE%");
- final Catalog catalog = SchemaCrawlerUtility.getCatalog(connection, sco);
- final Schema schema = catalog.getSchemas().iterator().next();
- if (catalog != null)
- {
- final Collection<Table> tablesList = catalog.getTables(schema);
- final Iterator<Table> i = tablesList.iterator();
- Table tbl;
- while (i.hasNext())
- {
- tbl = i.next();
- System.out.println(tbl);
- for (final Column col: tbl.getColumns())
- {
- final JavaSqlType sqlType = col.getColumnDataType().getJavaSqlType();
- System.out
- .println("o--> " + col.getName() + " -data-type- " + sqlType);
- }
- }
- }
- }
- private static Connection getConnection()
- throws SchemaCrawlerException, SQLException
- {
- final DataSource dataSource = new DatabaseConnectionOptions("jdbc:oracle:thin:@srvsvil:1521:orcl");
- return dataSource.getConnection("username", "password");
- }
- }
Add Comment
Please, Sign In to add comment