public void execute(ISQLEntryPanel sqlPanel) { removeErrorPanels(); String sql = sqlPanel.getSQLToBeExecuted(); if (sql != null && sql.length() > 0) { executeSQL(sql); } else { // i18n[SQLResultExecuterPanel.nosqlselected=No SQL selected for execution.] String msg = s_stringMgr.getString("SQLResultExecuterPanel.nosqlselected"); _session.showErrorMessage(msg); } }
public void actionPerformed(ActionEvent evt) { if (_session != null) { try { // new InQuotesCommand(_session.getSQLPanelAPI(_plugin)).execute(); new InQuotesCommand(FrameWorkAcessor.getSQLPanelAPI(_session, _plugin)).execute(); } catch (Throwable ex) { // i18n[editextras.errorQuoteSql=Error processing Quote SQL command: {0}] final String msg = s_stringMgr.getString("editextras.errorQuoteSql", ex); _session.showErrorMessage(msg); s_log.error(msg, ex); } } }
public void load(ISession session, PreparedStatement stmt) { ResultSet rs = null; try { rs = stmt.executeQuery(); StringBuffer buf = new StringBuffer(4096); while (rs.next()) { String line1 = rs.getString(1); String line2 = rs.getString(2); buf.append(line1.trim() + " "); buf.append(line2.trim() + " "); } String source = ""; if (buf.length() == 0 && sourceType == TABLE_TYPE) { ISQLDatabaseMetaData md = session.getMetaData(); // TODO: Need to define a better approach to getting dialects. // That is, we don't really want to ever prompt the user in this // case. It's always Oracle. Yet, we may have a new OracleDialect // at some point. HibernateDialect dialect = DialectFactory.getDialect("Oracle"); // TODO: How to let the user customize this?? CreateScriptPreferences prefs = new CreateScriptPreferences(); ITableInfo[] tabs = new ITableInfo[] {(ITableInfo) getDatabaseObjectInfo()}; List<ITableInfo> tables = Arrays.asList(tabs); // Handle table source List<String> sqls = dialect.getCreateTableSQL(tables, md, prefs, false); String sep = session.getQueryTokenizer().getSQLStatementSeparator(); for (String sql : sqls) { buf.append(sql); buf.append(sep); buf.append("\n"); } source = buf.toString(); } else { if (s_log.isDebugEnabled()) { s_log.debug("View source before formatting: " + buf.toString()); } source = formatter.reformat(buf.toString()); } getTextArea().setText(source); getTextArea().setCaretPosition(0); } catch (SQLException ex) { s_log.error("Unexpected exception: " + ex.getMessage(), ex); session.showErrorMessage(ex); } finally { SQLUtilities.closeResultSet(rs); } }
private void btCreateTableActionPerformed(java.awt.event.ActionEvent evt) { ISQLConnection con = _session.getSQLConnection(); String query = getQuery(); Statement stmt = null; try { stmt = con.createStatement(); stmt.execute(query); _session.getSessionInternalFrame().getObjectTreeAPI().refreshTree(); jd.setVisible(false); jd.dispose(); JOptionPane.showMessageDialog( null, // i18n[mysql.msgTableCreated=Table {0} created] s_stringMgr.getString("mysql.msgTableCreated", tfTableName.getText())); } catch (SQLException ex) { _session.showErrorMessage(ex); } finally { SQLUtilities.closeStatement(stmt); } }