public void loadValues(ConnectionWithParams cwp) { getPortTextField().setText(cwp.getPort()); selectThisInDriverCombo(cwp.getDrvName()); getDbTextField().setText(cwp.getDb()); getUserTextField().setText(cwp.getUser()); if (cwp.getPw() == null) { getPasswordField().setText(""); } else { getPasswordField().setText(cwp.getPw()); } getUrlTextArea().setText(cwp.getHost()); boolean connected = false; try { connected = (cwp.getConnection() != null) && (!cwp.getConnection().isClosed()); } catch (DBException e) { logger.error("While checking connection: " + e.getMessage()); connected = false; } getConnectedCheckBox().setSelected(connected); getConnNameTextField().setText(cwp.getName()); }
/** Called by the extension object when gvsig terminates. */ public void closeAllBeforeTerminate() { boolean ok = true; String key = ""; ConnectionWithParams cwp = null; Iterator iter = connections.keySet().iterator(); while (iter.hasNext()) { key = (String) iter.next(); cwp = (ConnectionWithParams) connections.get(key); if (cwp.getConnection() == null) continue; try { cwp.getConnection().close(); } catch (DBException se) { ok = false; logger.error("While closing connection: " + se.getMessage(), se); } } connections.clear(); if (ok) { logger.info("Successfully closed all connections."); } else { logger.warn("Problems while closing all connections."); } }