From c7e99a8ed3ae70051d7b6f6393d865bb56fe1e93 Mon Sep 17 00:00:00 2001 From: Owen Zou Date: Sun, 14 Aug 2016 09:20:55 +0800 Subject: [PATCH] =?UTF-8?q?1.=20=E6=94=AF=E6=8C=81PostgreSQL=202.=20?= =?UTF-8?q?=E4=BF=AE=E5=A4=8DConnection=E5=8F=AA=E8=83=BD=E6=89=93?= =?UTF-8?q?=E5=BC=80=E4=B8=80=E6=AC=A1=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- pom.xml | 5 +++++ .../zzg/mybatis/generator/controller/BaseFXController.java | 4 ++-- .../zzg/mybatis/generator/controller/MainUIController.java | 5 +++-- src/main/java/com/zzg/mybatis/generator/model/DbType.java | 3 ++- src/main/resources/fxml/newConnection.fxml | 1 + 6 files changed, 14 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 9299acad..9f6f5750 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ mybatis-generator-gui是基于[mybatis generator](http://www.mybatis.org/generat * 保存数据库连接与配置,每次代码生成轻松搞定 * 内置常用插件,比如offset * 可选的去除掉对版本管理不友好的注释,这样新增或删除字段重新生成的文件比较过来清楚 -* 目前仅支持Mysql与Oracle,如果有对其它数据库有需求的请提Issue我会跟进。 +* 目前已经支持Mysql、Oracle与PostgreSQL,如果有对其它数据库有需求的请提Issue我会跟进。 ### 要求 本工具由于使用了Java 8的众多特性,所以要求 JRE或者JDK 8.0以上版本,对于JDK版本还没有升级的童鞋表示歉意。 diff --git a/pom.xml b/pom.xml index da836397..bc1fd606 100644 --- a/pom.xml +++ b/pom.xml @@ -48,6 +48,11 @@ system ${project.basedir}/src/main/resources/lib/ojdbc14.jar + + org.postgresql + postgresql + 9.4.1209 + com.alibaba fastjson diff --git a/src/main/java/com/zzg/mybatis/generator/controller/BaseFXController.java b/src/main/java/com/zzg/mybatis/generator/controller/BaseFXController.java index 39eb5581..e6bc2c4f 100644 --- a/src/main/java/com/zzg/mybatis/generator/controller/BaseFXController.java +++ b/src/main/java/com/zzg/mybatis/generator/controller/BaseFXController.java @@ -26,9 +26,9 @@ public abstract class BaseFXController implements Initializable { private static Map> cacheNodeMap = new HashMap<>(); - public BaseFXController loadFXMLPage(String title, FXMLPage fxmlPage) { + public BaseFXController loadFXMLPage(String title, FXMLPage fxmlPage, boolean cache) { SoftReference parentNodeRef = cacheNodeMap.get(fxmlPage); - if (parentNodeRef != null) { + if (cache && parentNodeRef != null) { return parentNodeRef.get(); } URL skeletonResource = Thread.currentThread().getContextClassLoader().getResource(fxmlPage.getFxml()); diff --git a/src/main/java/com/zzg/mybatis/generator/controller/MainUIController.java b/src/main/java/com/zzg/mybatis/generator/controller/MainUIController.java index 866ebbaf..c7201240 100644 --- a/src/main/java/com/zzg/mybatis/generator/controller/MainUIController.java +++ b/src/main/java/com/zzg/mybatis/generator/controller/MainUIController.java @@ -99,8 +99,9 @@ public void initialize(URL location, ResourceBundle resources) { dbImage.setFitWidth(40); connectionLabel.setGraphic(dbImage); connectionLabel.setOnMouseClicked(event -> { - NewConnectionController controller = (NewConnectionController) loadFXMLPage("New Connection", FXMLPage.NEW_CONNECTION); + NewConnectionController controller = (NewConnectionController) loadFXMLPage("New Connection", FXMLPage.NEW_CONNECTION, false); controller.setMainUIController(this); + controller.showDialogStage(); }); leftDBTree.setShowRoot(false); @@ -260,7 +261,7 @@ public void openTableColumnCustomizationPage() { AlertUtil.showErrorAlert("Please select table from left DB treee first"); return; } - SelectTableColumnController controller = (SelectTableColumnController) loadFXMLPage("Select Columns", FXMLPage.SELECT_TABLE_COLUMN); + SelectTableColumnController controller = (SelectTableColumnController) loadFXMLPage("Select Columns", FXMLPage.SELECT_TABLE_COLUMN, true); controller.setMainUIController(this); try { // If select same schema and another table, update table data diff --git a/src/main/java/com/zzg/mybatis/generator/model/DbType.java b/src/main/java/com/zzg/mybatis/generator/model/DbType.java index 971e2ea8..b838174c 100644 --- a/src/main/java/com/zzg/mybatis/generator/model/DbType.java +++ b/src/main/java/com/zzg/mybatis/generator/model/DbType.java @@ -6,7 +6,8 @@ public enum DbType { MySQL("com.mysql.jdbc.Driver", "jdbc:mysql://%s:%s/%s?useUnicode=true&useSSL=false&characterEncoding=%s"), - Oracle("oracle.jdbc.driver.OracleDriver", "jdbc:oracle:thin:@%s:%s:%s"); + Oracle("oracle.jdbc.driver.OracleDriver", "jdbc:oracle:thin:@%s:%s:%s"), + PostgreSQL("org.postgresql.Driver", "jdbc:postgresql://%s:%s/%s"); private final String driverClass; private final String connectionUrlPattern; diff --git a/src/main/resources/fxml/newConnection.fxml b/src/main/resources/fxml/newConnection.fxml index 12bf2e3d..03b3f8a3 100644 --- a/src/main/resources/fxml/newConnection.fxml +++ b/src/main/resources/fxml/newConnection.fxml @@ -34,6 +34,7 @@ +