2015-06-09 30 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());