0

I am currently using Schemacrawler to gather information about various databases.

The issue I am having is that the user which the application runs under doesn't have access to every database. If I attempt to retrieve the list of schemas:

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

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

... a SchemaCrawlerException is thrown (The server principal "..." is not able to access the database "..." under the current security context.). Is there a way to get only the databases that are accessible (without having to explicitly declare each schema name)?

Nathan Hughes
  • 94,330
  • 19
  • 181
  • 276
Paul Adams
  • 75
  • 1
  • 5
  • Please take a look at http://stackoverflow.com/questions/7923424/using-java-schemacrawler-why-is-it-scanning-every-table-in-my-database – Sualeh Fatehi May 17 '12 at 19:28

1 Answers1

1

From the exception you are getting, I am going to assume that you are using SQL Server. You need to set a schema inclusion rule. You can add this to your code snippet above:

schemaCrawlerOptions.setSchemaInclusionRule(new InclusionRule("schema_name.dbo.*", ""));
Sualeh Fatehi
  • 4,700
  • 2
  • 24
  • 28