public void run() { String command = inputTextArea.getText().trim(); if (command == null || command.length() == 0) { JOptionPane.showMessageDialog( mainWindow, "Command window is empty", "Out of order", JOptionPane.WARNING_MESSAGE); return; } // make busy dialog same width as main window. Dimension dlgBounds = busyDialog.getSize(); dlgBounds.width = mainWindow.getSize().width; busyDialog.setSize(dlgBounds); runButton.setEnabled(false); Configuration config = (Configuration) connectionsList.getSelectedItem(); if (passwdPromptCheckBox.isSelected() || !config.hasPassword()) { String pass = getPassword("Connection password for " + config.getName()); config.setPassword(pass); } resultsStatusBar.reset(); busyDialog.setVisible(true); try { currentConnection = configManager.getConnection(config); SQLRunner.setVerbosity(Verbosity.QUIET); SQLRunner prog = new SQLRunner(currentConnection, null, "t"); prog.setGUI(SQLRunnerGUI.this); if (mode != null) { prog.setOutputMode(mode); } prog.setOutputFile(out); // RUN THE SQL prog.runStatement(command); if (prog.isEscape()) { outputPanel.setSelectedIndex(0); } resultsStatusBar.showSuccess(); // If no exception thrown! } catch (Exception e) { resultsStatusBar.showFailure(); eHandler.handleError(e); } finally { runButton.setEnabled(true); busyDialog.setVisible(false); try { // Nested try here is deliberate, not a big deal if this call crashes if (currentConnection != null) { currentConnection.close(); } } catch (SQLException ex) { System.err.println("Warning: close caused " + ex); } } }