需要Java API生成数据库ER图
-
09-12-2019 - |
题
是否有任何Java API / Java插件,可以在Java连接对象作为输入提供时生成数据库ER图。
ex:InputSream generateDatabaseERDiagram(java connection object)// where inputsream will point to generated ER diagram image
API应该使用Oracle,MySQL,PostgreSQL?
我正在经历schemacrawler(http://schemacrawler.sourceforge.net/)工具,但didint得到了任何可以执行此操作的API。
如果没有像这样的API,那么让我知道如何写自己的API?如果架构名称作为输入提供,我想为数据库中的所有模式生成ER图表或任何特定架构。
如果您在如何实现此任务时显示一些亮起会有所帮助。
解决方案
如果我理解你的问题,你可能会看看: jgraph
其他提示
这是一个古老的问题,但如果我在尝试做同样的事情时,如果我在尝试做同样的事情时,我最终弄清楚了如何使用架构的Java API来生成ERD。
//Get your java connection however
Connection conn = DriverManager.getConnection("DATABASE URL");
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());
// you can exclude/include objects using the options object e.g.
//options.setTableInclusionRule(new RegularExpressionExclusionRule(".*qrtz.*||.*databasechangelog.*"));
GraphExecutable ge = new GraphExecutable();
ge.setSchemaCrawlerOptions(options);
String outputFormatValue = GraphOutputFormat.png.getFormat();
OutputOptions outputOptions = new OutputOptions(outputFormatValue, new File("database.png").toPath());
ge.setOutputOptions(outputOptions);
ge.execute(conn);
.
仍然需要 graphviz 要安装和在工作路径上。
不隶属于 StackOverflow