Guest User

Untitled

a guest
Mar 10th, 2018
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.46 KB | None | 0 0
  1. import static us.fatehi.commandlineparser.CommandLineUtility.applyApplicationLogLevel;
  2. import static us.fatehi.commandlineparser.CommandLineUtility.logSystemProperties;
  3.  
  4. import java.sql.Connection;
  5. import java.sql.SQLException;
  6. import java.util.Collection;
  7. import java.util.Iterator;
  8. import java.util.logging.Level;
  9.  
  10. import javax.sql.DataSource;
  11.  
  12. import schemacrawler.schema.Catalog;
  13. import schemacrawler.schema.Column;
  14. import schemacrawler.schema.JavaSqlType;
  15. import schemacrawler.schema.Schema;
  16. import schemacrawler.schema.Table;
  17. import schemacrawler.schemacrawler.DatabaseConnectionOptions;
  18. import schemacrawler.schemacrawler.ExcludeAll;
  19. import schemacrawler.schemacrawler.RegularExpressionInclusionRule;
  20. import schemacrawler.schemacrawler.SchemaCrawlerException;
  21. import schemacrawler.schemacrawler.SchemaCrawlerOptions;
  22. import schemacrawler.tools.options.InfoLevel;
  23. import schemacrawler.utility.SchemaCrawlerUtility;
  24.  
  25. public final class Issue167
  26. {
  27.  
  28. public static void main(final String[] args)
  29. throws Exception
  30. {
  31. // Turn application logging on by applying the correct log level
  32. applyApplicationLogLevel(Level.OFF);
  33. // Log system properties and classpath
  34. logSystemProperties();
  35.  
  36. final Connection connection = getConnection();
  37. final SchemaCrawlerOptions sco = new SchemaCrawlerOptions();
  38. sco.setSchemaInfoLevel(InfoLevel.standard.buildSchemaInfoLevel());
  39. sco.setRoutineInclusionRule(new ExcludeAll());
  40. sco
  41. .setSchemaInclusionRule(new RegularExpressionInclusionRule("SVIL"));
  42. sco.setTableNamePattern("XGPI_DDL_ORACLE%");
  43. final Catalog catalog = SchemaCrawlerUtility.getCatalog(connection, sco);
  44. final Schema schema = catalog.getSchemas().iterator().next();
  45. if (catalog != null)
  46. {
  47. final Collection<Table> tablesList = catalog.getTables(schema);
  48. final Iterator<Table> i = tablesList.iterator();
  49. Table tbl;
  50. while (i.hasNext())
  51. {
  52. tbl = i.next();
  53. System.out.println(tbl);
  54. for (final Column col: tbl.getColumns())
  55. {
  56. final JavaSqlType sqlType = col.getColumnDataType().getJavaSqlType();
  57. System.out
  58. .println("o--> " + col.getName() + " -data-type- " + sqlType);
  59. }
  60. }
  61. }
  62.  
  63. }
  64.  
  65. private static Connection getConnection()
  66. throws SchemaCrawlerException, SQLException
  67. {
  68. final DataSource dataSource = new DatabaseConnectionOptions("jdbc:oracle:thin:@srvsvil:1521:orcl");
  69. return dataSource.getConnection("username", "password");
  70. }
  71.  
  72. }
Add Comment
Please, Sign In to add comment