use of com.zzg.mybatis.generator.model.DatabaseConfig in project mybatis-generator-gui by zouzg.
the class DbConnectionController method extractConfigForUI.
public DatabaseConfig extractConfigForUI() {
String name = nameField.getText();
String host = hostField.getText();
String port = portField.getText();
String userName = userNameField.getText();
String password = passwordField.getText();
String encoding = encodingChoice.getValue();
String dbType = dbTypeChoice.getValue();
String schema = schemaField.getText();
DatabaseConfig config = new DatabaseConfig();
config.setName(name);
config.setDbType(dbType);
config.setHost(host);
config.setPort(port);
config.setUsername(userName);
config.setPassword(password);
config.setSchema(schema);
config.setEncoding(encoding);
if (StringUtils.isAnyEmpty(name, host, port, userName, encoding, dbType, schema)) {
AlertUtil.showWarnAlert("密码以外其他字段必填");
return null;
}
return config;
}
use of com.zzg.mybatis.generator.model.DatabaseConfig in project mybatis-generator-gui by zouzg.
the class DbConnectionController method saveConnection.
final void saveConnection() {
DatabaseConfig config = extractConfigForUI();
if (config == null) {
return;
}
try {
ConfigHelper.saveDatabaseConfig(this.isUpdate, primayKey, config);
this.tabPaneController.getDialogStage().close();
mainUIController.loadLeftDBTree();
} catch (Exception e) {
_LOG.error(e.getMessage(), e);
AlertUtil.showErrorAlert(e.getMessage());
}
}
use of com.zzg.mybatis.generator.model.DatabaseConfig in project mybatis-generator-gui by zouzg.
the class OverSshController method checkInput.
@FXML
public void checkInput() {
DatabaseConfig databaseConfig = extractConfigFromUi();
if (authTypeChoice.getValue().equals("Password") && (StringUtils.isBlank(databaseConfig.getSshHost()) || StringUtils.isBlank(databaseConfig.getSshPort()) || StringUtils.isBlank(databaseConfig.getSshUser()) || StringUtils.isBlank(databaseConfig.getSshPassword())) || authTypeChoice.getValue().equals("PubKey") && (StringUtils.isBlank(databaseConfig.getSshHost()) || StringUtils.isBlank(databaseConfig.getSshPort()) || StringUtils.isBlank(databaseConfig.getSshUser()) || StringUtils.isBlank(databaseConfig.getPrivateKey()))) {
note.setText("当前SSH配置输入不完整,OVER SSH不生效");
note.setTextFill(Paint.valueOf("#ff666f"));
} else {
note.setText("当前SSH配置生效");
note.setTextFill(Paint.valueOf("#5da355"));
}
}
use of com.zzg.mybatis.generator.model.DatabaseConfig in project mybatis-generator-gui by zouzg.
the class OverSshController method extractConfigFromUi.
public DatabaseConfig extractConfigFromUi() {
String name = nameField.getText();
String host = hostField.getText();
String port = portField.getText();
String userName = userNameField.getText();
String password = passwordField.getText();
String encoding = encodingChoice.getValue();
String dbType = dbTypeChoice.getValue();
String schema = schemaField.getText();
String authType = authTypeChoice.getValue();
DatabaseConfig config = new DatabaseConfig();
config.setName(name);
config.setDbType(dbType);
config.setHost(host);
config.setPort(port);
config.setUsername(userName);
config.setPassword(password);
config.setSchema(schema);
config.setEncoding(encoding);
config.setSshHost(this.sshHostField.getText());
config.setSshPort(this.sshdPortField.getText());
config.setLport(this.lportField.getText());
config.setRport(this.rportField.getText());
config.setSshUser(this.sshUserField.getText());
config.setSshPassword(this.sshPasswordField.getText());
if ("PubKey".equals(authType)) {
config.setPrivateKey(this.privateKey.getAbsolutePath());
config.setPrivateKeyPassword(this.sshPubkeyPasswordField.getText());
}
return config;
}
use of com.zzg.mybatis.generator.model.DatabaseConfig in project mybatis-generator-gui by zouzg.
the class ConfigHelper method loadDatabaseConfig.
public static List<DatabaseConfig> loadDatabaseConfig() throws Exception {
Connection conn = null;
Statement stat = null;
ResultSet rs = null;
try {
conn = ConnectionManager.getConnection();
stat = conn.createStatement();
rs = stat.executeQuery("SELECT * FROM dbs");
List<DatabaseConfig> configs = new ArrayList<>();
while (rs.next()) {
int id = rs.getInt("id");
String value = rs.getString("value");
DatabaseConfig databaseConfig = JSON.parseObject(value, DatabaseConfig.class);
databaseConfig.setId(id);
configs.add(databaseConfig);
}
return configs;
} finally {
if (rs != null)
rs.close();
if (stat != null)
stat.close();
if (conn != null)
conn.close();
}
}
Aggregations