schemacrawler / SchemaCrawler

Free database schema discovery and comprehension tool
http://www.schemacrawler.com/
Other
1.6k stars 199 forks source link

Command Line produces correct results with Oracle, while API misses tables #239

Closed jseaman-idata closed 5 years ago

jseaman-idata commented 5 years ago

Command Line runs Oracle scan correctly sourcing DBA_* objects for metadata, but API is still using ALL_TABLES, etc.. This was using the same credentials in both calls. In older versions of SchemaCrawler it always just queried ALL_TABLES. In the newer source code, it first trial queries DBA_TABLES to see if the current account has permissions to query it. This new behavior is desired, but when running from the API, it always queries ALL_TABLES. No idea why.

This is with ojdbc7.jar and schemacrawler-5.01.05.jar in linux using JDK_1.8.X

sualeh commented 5 years ago

@jseaman-idata - how are you building the SchemaRetrievalOptions? Can you post your code?

jseaman-idata commented 5 years ago

Here's some code snippits to give context:

InfoLevel schemaInfoLevel; schemaInfoLevel = InfoLevel.maximum;

schemaCrawlerOptionsBuilder = SchemaCrawlerOptionsBuilder .builder().withSchemaInfoLevel(schemaInfoLevel.buildSchemaInfoLevel()) .includeSchemas(new RegularExpressionRule(schemaInclusionList, schemaExclusionList)) .includeAllRoutines() .includeTables(new RegularExpressionInclusionRule(tableInclusionList)); schemaCrawlerOptions = schemaCrawlerOptionsBuilder .toOptions();

final OutputOptions outputOptions = OutputOptionsBuilder .newOutputOptions(textOutputFormat, filePath); final String command = "schema";

        final SchemaCrawlerExecutable executable = new SchemaCrawlerExecutable(command);
        executable.setSchemaCrawlerOptions(schemaCrawlerOptions);
        executable.setOutputOptions(outputOptions);
        executable.setConnection(getConnection());
        executable.execute();
jseaman-idata commented 5 years ago

I posted the following to the ticket (but it occurs to me I don't think I set SchemaRetrievalOptions explicitly:

InfoLevel schemaInfoLevel; schemaInfoLevel = InfoLevel.maximum;

schemaCrawlerOptionsBuilder = SchemaCrawlerOptionsBuilder .builder().withSchemaInfoLevel(schemaInfoLevel.buildSchemaInfoLevel()) .includeSchemas(new RegularExpressionRule(schemaInclusionList, schemaExclusionList)) .includeAllRoutines() .includeTables(new RegularExpressionInclusionRule(tableInclusionList)); schemaCrawlerOptions = schemaCrawlerOptionsBuilder .toOptions();

final OutputOptions outputOptions = OutputOptionsBuilder .newOutputOptions(textOutputFormat, filePath); final String command = "schema";

final SchemaCrawlerExecutable executable = new

SchemaCrawlerExecutable(command); executable.setSchemaCrawlerOptions(schemaCrawlerOptions); executable.setOutputOptions(outputOptions); executable.setConnection(getConnection()); executable.execute();

On Fri, Dec 14, 2018 at 8:20 PM Sualeh Fatehi notifications@github.com wrote:

@jseaman-idata https://github.com/jseaman-idata - how are you building the SchemaRetrievalOptions? Can you post your code?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/schemacrawler/SchemaCrawler/issues/239#issuecomment-447524338, or mute the thread https://github.com/notifications/unsubscribe-auth/ARgVuNNROF5rK8G4-o5R0o73uvphEbYqks5u5E5QgaJpZM4ZUHat .

-- Jeff Seaman Senior Software Engineer IData, Inc - http://www.idatainc.com Data Management for Higher Education jseaman@idatainc.com Office: (703) 378-2110 x80 <%28703%29%20378-2110%20x825>4

sualeh commented 5 years ago

Please take a look at Issue239.java which shows how to set the SchemaRetrievalOptions. If you use databases other than Oracle, you can write that code in a slightly better way.

jseaman-idata commented 5 years ago

Thank you. That was very helpful. When is it recommended to use the database specific plugins, vs. the way I was doing it?

On Sat, Dec 15, 2018 at 3:16 PM Sualeh Fatehi notifications@github.com wrote:

Please take a look at Issue239.java https://gist.github.com/sualeh/57159a2d44439c90f16b1db399421284 which shows how to set the SchemaRetrievalOptions. If you use databases other than Oracle, you can write that code in a slightly better way.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/schemacrawler/SchemaCrawler/issues/239#issuecomment-447594992, or mute the thread https://github.com/notifications/unsubscribe-auth/ARgVuN-e5hzY1gW7jqxLLNk_CDCnGwxIks5u5ViOgaJpZM4ZUHat .

-- Jeff Seaman Senior Software Engineer IData, Inc - http://www.idatainc.com Data Management for Higher Education jseaman@idatainc.com Office: (703) 378-2110 x80 <%28703%29%20378-2110%20x825>4

sualeh commented 5 years ago

@jseaman-idata - did that code work for you?

You should not have to do this, since the SchemaRetrievalOptions are matched in SchemaCrawlerExecutable.execute, so I am trying to understand why your code did not work. The only explanation I have is that the SchemaCrawler Oracle plugin was not on your classpath. The code I gave you ensures that the SchemaCrawler Oracle plugin is on your classpath.

jseaman-idata commented 5 years ago

Oh, well I've been using SchemaCrawler without any of the plugins. My mistake :) I only recently refactored to use the latest versions as I was using a version of SchemaCrawler that was about a year and a half old and the API had changed a bit (increasing/adding the use of builders as well as other organizational changes).

Thanks again tons. I'm adding use of the plugins now.

On Sun, Dec 16, 2018 at 9:49 AM Sualeh Fatehi notifications@github.com wrote:

You should not have to do this, since the SchemaRetrievalOptions are matched in SchemaCrawlerExecutable.execute https://github.com/schemacrawler/SchemaCrawler/blob/master/schemacrawler-tools/src/main/java/schemacrawler/tools/executable/SchemaCrawlerExecutable.java#L106-L110

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/schemacrawler/SchemaCrawler/issues/239#issuecomment-447648932, or mute the thread https://github.com/notifications/unsubscribe-auth/ARgVuJZzlJkorT3RenYgaHRmidPOrKi_ks5u5l1ugaJpZM4ZUHat .

-- Jeff Seaman Senior Software Engineer IData, Inc - http://www.idatainc.com Data Management for Higher Education jseaman@idatainc.com Office: (703) 378-2110 x80 <%28703%29%20378-2110%20x825>4

sualeh commented 5 years ago

@jseaman-idata - SchemaCrawler will pick up plugins automatically from the classpath. You do not need to explicitly use the plugins as long as you ensure that the SchemaCrawler plugins are in fact on your classpath. The code I gave you was to force compilation to fail if the SchemaCrawler Oracle plugin was not on your classpth. In other words, your original code will work.