2015-06-09 50 views
0

我無法檢索SQL Server 2012中的表。Schemacrawler無法在SQL Server中檢索表

使用該API,我無法獲取任何表。如果我設置爲false架構的支持,我得到的表,但沒有列:

 SchemaCrawlerOptions options = new SchemaCrawlerOptions(); 
     options.setSchemaInclusionRule(new RegularExpressionInclusionRule(databaseName)); 
     options.setRoutineInclusionRule(new ExcludeAll()); 
     //options.getDatabaseSpecificOverrideOptions().setSupportsSchemas(false); 
     options.setTableInclusionRule(new RegularExpressionInclusionRule("(?i)|databaseName.\\W?+myTable\\W?+")); 
     options.setSchemaInfoLevel(SchemaInfoLevel.standard()); 
     Catalog database = SchemaCrawlerUtility.getCatalog(connection, options); 

     for (Table t : database.getTables()) { 
      System.out.println("Table: " + t.getName()); 
      for (Column c : t.getColumns()) { 
       System.out.println("Column: " + c.getName()); 
      } 
     } 

使用sc.cmd,我沒有得到任何表都:

sc -url=jdbc:jtds:sqlserver://<server>:1433/<dbname> -user=<user> -password=<pwd> -c=brief -infolevel=standard -schemas=<dbname> -tables=.*\.<mytable>.* -outputformat=text 


System Information 
======================================================================== 
SchemaCrawler Information 
-=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=- 
product name        SchemaCrawler 
product version       12.06.03 

Database Information 
-=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=-  
database product name      Microsoft SQL Server 
database product version     11.00.3128 
database user name      <user> 

JDBC Driver Information 
-=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=- 
driver name        jTDS Type 4 JDBC Driver for MS SQL Server and Sybase 
driver version       1.3.1 
driver class name       net.sourceforge.jtds.jdbc.Driver 
url          jdbc:jtds:sqlserver://<server>:1433/<dbname> 
is JDBC compliant       false 

我試過在MySQL ,它工作正常。

回答

1

通過向模式名稱中添加目錄名稱(即「catalog_name.schema_name」)來實現它。

0

明白它只適用於選項:options.setSchemaInfoLevel(SchemaInfoLevel.standard());