Skip to content

Commit

Permalink
增加删除数据库连接的功能
Browse files Browse the repository at this point in the history
  • Loading branch information
zouzg committed Aug 21, 2016
1 parent 2056517 commit 59f2e52
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,17 @@ public void initialize(URL location, ResourceBundle resources) {
item1.setOnAction(event1 -> {
treeItem.getChildren().clear();
});
MenuItem item2 = new MenuItem("Delete");
MenuItem item2 = new MenuItem("Delete Connection");
item2.setOnAction(event1 -> {
// TODO
DatabaseConfig selectedConfig = (DatabaseConfig) treeItem.getGraphic().getUserData();
try {
ConfigHelper.deleteDatabaseConfig(selectedConfig.getName());
this.loadLeftDBTree();
} catch (Exception e) {
AlertUtil.showErrorAlert("Delete connection failed! Reason: " + e.getMessage());
}
});
contextMenu.getItems().addAll(item1);
contextMenu.getItems().addAll(item1, item2);
cell.setContextMenu(contextMenu);
}
if (event.getClickCount() == 2) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public static void deleteDatabaseConfig(String name) throws Exception {
try {
conn = ConnectionManager.getConnection();
stat = conn.createStatement();
String sql = String.format("delete from dbs where name=%s", name);
String sql = String.format("delete from dbs where name='%s'", name);
stat.executeUpdate(sql);
} finally {
if (rs != null) rs.close();
Expand Down

0 comments on commit 59f2e52

Please sign in to comment.