public boolean saveList(String path) { Properties properties = LocalResourcesUtil.getProperties(path); Iterator<Object> dbsKeys = properties.keySet().iterator(); String dbsPath = path.substring(0, path.lastIndexOf(File.separator) + 1); while (dbsKeys.hasNext()) { String key = dbsKeys.next().toString().trim(); String value = properties.getProperty(key).trim(); FileUtils.deleteFile(StringUtils.unite(dbsPath, value)); } for (int i = 0; i < dbConnectionInfoList.size(); i++) { DBConnectionInfo dbConnectionInfo = dbConnectionInfoList.get(i); String key = dbConnectionInfo.getDbCode(); try { String name = StringUtils.unite(key, "DBConfig.properties"); if (properties.get(key) != null) { name = properties.getProperty(key); } FileOutputStream fos = new FileOutputStream(StringUtils.unite(dbsPath, name)); fos.write(dbConnectionInfo.toString().getBytes()); fos.close(); } catch (IOException e) { logger.error(e.getMessage(), e); } } return true; }
@Override public void setValueAt(Object value, int row, int col) { DBConnectionInfo tmp = dbConnectionInfoList.get(row); if (tmp == null || value == null) { return; } switch (col) { case 0: tmp.setDbCode(value.toString()); break; case 1: tmp.setDbAddress(value.toString()); break; case 2: tmp.setDbPort(value.toString()); break; case 3: tmp.setDbType(DBType.valueOf(value.toString())); break; case 4: tmp.setDbName(value.toString()); break; case 5: tmp.setDbUsername(value.toString()); break; case 6: tmp.setDbPassword(value.toString()); break; case 7: tmp.setDbTestSQL(value.toString()); break; case 8: tmp.setMaxConnectionNum(Integer.valueOf(value.toString())); break; case 9: tmp.setMinConnectionNum(Integer.valueOf(value.toString())); break; } DBType dbtype = tmp.getDbType() == null ? DBType.MYSQL : tmp.getDbType(); tmp.initConnectionString(ConfigDbUtil.init().getConnectionStringFormat(dbtype)); for (int i = 0; i < title.length; i++) { this.fireTableCellUpdated(row, i); } }