[英]Required Java API to generate Database ER diagram
当提供java连接对象作为输入时,是否有任何java API / java插件可以生成数据库ER图。
例如: 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图(如果模式名称作为输入提供)。
如果您对如何完成此任务有所了解,将会很有帮助。
这是一个老问题但是如果其他人偶然发现它,就像我在尝试做同样的事情时所做的那样,我最终想出了如何使用Schemacrawler的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并在路径上工作。
如果我理解你的问题,你可以看看: JGraph
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.