2016-08-11 2 views
0

블로우 코드를 인쇄 할 수 없습니다. 데이터베이스 이름 만 인쇄하면 왜됩니까? schemacrawlar는 테이블 이름

public static void main(final String[] args) throws Exception 
    { 
     // Create a database connection 
     final DataSource dataSource = new DatabaseConnectionOptions("jdbc:mysql://localhost:3306/target_db"); 
     final Connection connection = dataSource.getConnection("root", "password"); 

     // Create the options 
     final SchemaCrawlerOptions options = new SchemaCrawlerOptions(); 
     options.setSchemaInfoLevel(SchemaInfoLevelBuilder.standard()); 

     options.setTableTypes(Lists.newArrayList("BASE TABLE","TABLE","VIEW")); 
     options.setRoutineInclusionRule(new ExcludeAll()); 
     options.setSchemaInclusionRule(new RegularExpressionInclusionRule("target_db")); 
     options.setTableNamePattern("*"); 

     // Get the schema definition 
     final Catalog catalog = SchemaCrawlerUtility.getCatalog(connection, options); 

     for (final Schema schema : catalog.getSchemas()) 
     { 
      System.out.print("c--> " + schema.getCatalogName() + "\n"); 

      for (final Table table : catalog.getTables(schema)) 
      { 

       System.out.print("o--> " + table); 
       if (table instanceof View) 
       { 
        System.out.println(" (VIEW)"); 
       } else 
       { 
        System.out.println(); 
       } 

       for (final Column column : table.getColumns()) 
       { 
        System.out.println("  o--> " + column + " (" + column.getColumnDataType() + ")"); 
       } 
      } 
     } 
    } 
} 

이상하게

,

./schemacrawler.sh -server=mysql -database=target_db -user=root -password=password -infolevel=ALL -command=schema 

가 출력 테이블과 열을 맞습니다.

업데이트 :

schemacrawler-14.09.03-main 
    Ubuntu 16.04 64bit 
    MariaDB 10.2.1-MariaDB-1~xenial 
    (I assumed mariadb may not be supported yet,so switch between blow two drivers,but neither works) 
    mysql-connector-java-6.0.3 
mariadb-java-client-1.4.6 
+0

"UNKNOWN"입니다 당신은 어떤 JDBC 드라이버 버전, 각 클래스 패스에 jar 파일이 있는지, 그리고 왜 명령 행에서와 다른 코드를 SchemaCrawler 옵션에 설정 하는가? –

답변

0

마지막으로 내 구성, 나는 그것을 알아 냈 :

options.setTableTypes(Lists.newArrayList("BASE TABLE","TABLE","VIEW","UNKNOWN")); 

주의 : MariaDB로, 테이블 유형은 데이터베이스의 버전은 무엇