private boolean getDbObjects(String type) { if (type.equals(BuggyMasterCodeApp.C_DB_TYPE_ORACLE)) { BuggyMasterCodeApp.setDb(new DBOracle()); BuggyMasterCodeApp.setDbBuggyMasterCode(new DBOracleBuggyMasterCode()); } else if (type.equals(BuggyMasterCodeApp.C_DB_TYPE_H2)) { BuggyMasterCodeApp.setDb(new DBH2()); BuggyMasterCodeApp.setDbBuggyMasterCode(new DBH2BuggyMasterCode()); } else { BuggyMasterCodeApp.getLogger() .log(Level.WARNING, "the database type " + type + " is not implemented yet"); return false; } return true; }
public boolean initDialog() { Logger logger = BuggyMasterCodeApp.getLogger(); logger.info("loading configuration from BuggyMasterCodeApp.properties"); try { Properties p = new Properties(); p.load(new FileInputStream("BuggyMasterCodeApp.properties")); m_type = p.getProperty("db_type"); m_server = p.getProperty("db_server"); m_database = p.getProperty("db_database"); m_user = p.getProperty("db_user"); m_password = p.getProperty("db_password"); } catch (Exception ex) { logger.log( Level.WARNING, "failed loading configuration from BuggyMasterCodeApp.properties", ex); return false; } this.txUser.setText(m_user); this.txPwd.setText(m_password); this.txServer.setText(m_server); logger.info("creating database objects"); if (!getDbObjects(m_type)) { logger.log(Level.WARNING, "failed creating database objects"); return false; } return true; }
@Action public void login() { BuggyMasterCodeApp.getLogger().info("connecting to database"); if (Db.db.connect( this.txServer.getText(), this.txUser.getText(), new String(this.txPwd.getPassword()))) { m_ok = true; this.setVisible(false); } else { G.showInfo("Connection to database " + this.txServer.getText() + " couldn't be established"); } }