2012-05-14 75 views
0

我目前使用Schemacrawler来收集有关各种数据库的信息。Schemacrawler忽略无法访问的模式

我遇到的问题是运行该应用程序的用户无法访问每个数据库。如果我尝试检索模式的列表:

SchemaCrawlerOptions schemaCrawlerOptions = new SchemaCrawlerOptions(); 
schemaCrawlerOptions.setSchemaInfoLevel(SchemaInfoLevel.minimum()); 
schemaCrawlerOptions.setTableTypes(new TableType[] { TableType.table }); 

Database database = SchemaCrawlerUtility.getDatabase(connection, schemaCrawlerOptions); 
database.getSchemas() 

...一个SchemaCrawlerException被抛出(服务器主体“...”不能访问数据库“...”当前安全上下文)。有没有办法只获取可访问的数据库(不必显式声明每个模式名称)?

+0

请看一看http://stackoverflow.com/questions/7923424/using-java-schemacrawler-why-is-it-scanning-every-table在我的数据库 –

回答

1

从你得到的异常中,我将假设你正在使用SQL Server。您需要设置架构包含规则。您可以添加到您的代码段中:

schemaCrawlerOptions.setSchemaInclusionRule(new InclusionRule("schema_name.dbo.*", "")); 
+0

我曾考虑过这一点,但只是检查我没有配置错误的东西。谢谢。 –