Skip to content

Commit

Permalink
1. 支持PostgreSQL 2. 修复Connection只能打开一次的bug
Browse files Browse the repository at this point in the history
  • Loading branch information
zouzg committed Aug 14, 2016
1 parent 60bb0dd commit c7e99a8
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 6 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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版本还没有升级的童鞋表示歉意。
Expand Down
5 changes: 5 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@
<scope>system</scope>
<systemPath>${project.basedir}/src/main/resources/lib/ojdbc14.jar</systemPath>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>9.4.1209</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ public abstract class BaseFXController implements Initializable {

private static Map<FXMLPage, SoftReference<? extends BaseFXController>> cacheNodeMap = new HashMap<>();

public BaseFXController loadFXMLPage(String title, FXMLPage fxmlPage) {
public BaseFXController loadFXMLPage(String title, FXMLPage fxmlPage, boolean cache) {
SoftReference<? extends BaseFXController> parentNodeRef = cacheNodeMap.get(fxmlPage);
if (parentNodeRef != null) {
if (cache && parentNodeRef != null) {
return parentNodeRef.get();
}
URL skeletonResource = Thread.currentThread().getContextClassLoader().getResource(fxmlPage.getFxml());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/com/zzg/mybatis/generator/model/DbType.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/fxml/newConnection.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
<FXCollections fx:factory="observableArrayList">
<String fx:value="MySQL" />
<String fx:value="Oracle" />
<String fx:value="PostgreSQL" />
</FXCollections>
</items>
</ChoiceBox>
Expand Down

0 comments on commit c7e99a8

Please sign in to comment.