【发布时间】:2016-10-26 08:45:19
【问题描述】:
我认为标题说明了一切:有没有一种很好的方法可以使用 SchemaCrawler 创建和加载数据库模式的离线快照,而无需使用命令行?如果是,您能否提供一些示例代码/链接?如果没有,一些使用命令行选项的示例 java 代码也会有所帮助(我没有太多经验)!
感谢您的任何帮助!
PS:我设法用这段代码创建了离线快照:
final SchemaCrawlerOptions options = new SchemaCrawlerOptions();
// Set what details are required in the schema - this affects the
// time taken to crawl the schema
options.setSchemaInfoLevel(SchemaInfoLevelBuilder.standard());
options.setRoutineInclusionRule(new ExcludeAll());
options.setSchemaInclusionRule(new RegularExpressionInclusionRule(/* some regex here*/));
options.setTableInclusionRule(new RegularExpressionExclusionRule(/*some regex here*/));
outputOptions.setCompressedOutputFile(Paths.get("./test_db_snapshot.xml"));
final String command = "serialize";
final Executable executable = new SchemaCrawlerExecutable(command);
executable.setSchemaCrawlerOptions(options);
executable.setOutputOptions(outputOptions);
executable.execute(getConnection());
不知道如何连接它。
【问题讨论】:
标签: java schemacrawler