private static ConnectionWrapper connect(String url) { try { return new ConnectionWrapper(DriverManager.getConnection(url, username, password)); } catch (SQLException e) { int errorCode = e.getErrorCode(); if (errorCode == 1044 || errorCode == 1045) { String host = PreferenceManager.getInstance().get(PreferenceManager.DB_HOST); Frame parent = Globals.isHeadless() ? null : IGV.getMainFrame(); LoginDialog dlg = new LoginDialog(parent, false, host, false); dlg.setVisible(true); if (dlg.isCanceled()) { throw new RuntimeException("Must login to access" + host); } username = dlg.getUsername(); password = new String(dlg.getPassword()); return connect(url); } else { MessageUtils.showMessage("<html>Error connecting to database: <br>" + e.getMessage()); return null; } } }