Search in sources :

Example 1 with SQLConnection

use of net.sourceforge.sqlexplorer.dbproduct.SQLConnection in project tdq-studio-se by Talend.

the class ConnectionTreeActionGroup method fillContextMenu.

/**
 * Fill the node context menu with all the correct actions.
 *
 * @see org.eclipse.ui.actions.ActionGroup#fillContextMenu(org.eclipse.jface.action.IMenuManager)
 */
public void fillContextMenu(IMenuManager menu) {
    ConnectionsView view = SQLExplorerPlugin.getDefault().getConnectionsView();
    Object[] selection = (view == null) ? null : view.getSelected();
    // If nothing is selected, then show the default ones
    if (selection == null || selection.length != 1) {
        // addAction(menu, new CloseAllConnectionsAction());
        return;
    }
    if (selection[0] instanceof Alias) {
        Alias alias = (Alias) selection[0];
        addAction(menu, new NewEditorAction());
        addAction(menu, new NewDatabaseStructureViewAction());
        addAction(menu, new ConnectAliasAction());
        menu.add(new Separator());
        for (User user : alias.getUsers()) if (!user.isAutoCommit()) {
            addAction(menu, new CommitAction());
            addAction(menu, new RollbackAction());
            menu.add(new Separator());
            break;
        }
    // addAction(menu, new NewUserAction());
    // addAction(menu, new ChangeAliasAction());
    // addAction(menu, new CopyAliasAction());
    // addAction(menu, new DeleteAction());
    } else if (selection[0] instanceof User) {
        User user = (User) selection[0];
        addAction(menu, new NewEditorAction());
        addAction(menu, new NewDatabaseStructureViewAction());
        addAction(menu, new ConnectAliasAction());
        menu.add(new Separator());
        if (!user.isAutoCommit()) {
            addAction(menu, new CommitAction());
            addAction(menu, new RollbackAction());
            menu.add(new Separator());
        }
    // addAction(menu, new NewUserAction());
    // addAction(menu, new EditUserAction());
    // addAction(menu, new CopyUserAction());
    // addAction(menu, new DeleteAction());
    } else if (selection[0] instanceof SQLConnection) {
        SQLConnection connection = (SQLConnection) selection[0];
        addAction(menu, new NewEditorAction());
        addAction(menu, new NewDatabaseStructureViewAction());
        menu.add(new Separator());
        if (!connection.getUser().isAutoCommit()) {
            addAction(menu, new CommitAction());
            addAction(menu, new RollbackAction());
            menu.add(new Separator());
        }
    // addAction(menu, new CloseConnectionAction());
    }
}
Also used : User(net.sourceforge.sqlexplorer.dbproduct.User) NewDatabaseStructureViewAction(net.sourceforge.sqlexplorer.connections.actions.NewDatabaseStructureViewAction) Alias(net.sourceforge.sqlexplorer.dbproduct.Alias) SQLConnection(net.sourceforge.sqlexplorer.dbproduct.SQLConnection) NewEditorAction(net.sourceforge.sqlexplorer.connections.actions.NewEditorAction) ConnectAliasAction(net.sourceforge.sqlexplorer.connections.actions.ConnectAliasAction) RollbackAction(net.sourceforge.sqlexplorer.connections.actions.RollbackAction) Separator(org.eclipse.jface.action.Separator) CommitAction(net.sourceforge.sqlexplorer.connections.actions.CommitAction)

Example 2 with SQLConnection

use of net.sourceforge.sqlexplorer.dbproduct.SQLConnection in project tdq-studio-se by Talend.

the class ConnectionsView method getSelectedAliases.

/**
 * Returns a list of the selected Aliases. If recurse is true then the result will include any aliases associated
 * with other objects; eg, if a connection is selected and recurse is true, then the connection's alias will also be
 * returned
 *
 * @param recurse
 * @return Set of Aliases, never returns null
 */
public Set<Alias> getSelectedAliases(boolean recurse) {
    IStructuredSelection selection = (IStructuredSelection) _treeViewer.getSelection();
    if (selection == null) {
        return EMPTY_ALIASES;
    }
    LinkedHashSet<Alias> result = new LinkedHashSet<Alias>();
    Iterator iter = selection.iterator();
    while (iter.hasNext()) {
        Object obj = iter.next();
        if (obj instanceof Alias) {
            result.add((Alias) obj);
        } else if (recurse) {
            if (obj instanceof User) {
                User user = (User) obj;
                result.add(user.getAlias());
            } else if (obj instanceof SQLConnection) {
                SQLConnection connection = (SQLConnection) obj;
                result.add(connection.getUser().getAlias());
            }
        }
    }
    return result;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) User(net.sourceforge.sqlexplorer.dbproduct.User) Alias(net.sourceforge.sqlexplorer.dbproduct.Alias) SQLConnection(net.sourceforge.sqlexplorer.dbproduct.SQLConnection) Iterator(java.util.Iterator) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection)

Example 3 with SQLConnection

use of net.sourceforge.sqlexplorer.dbproduct.SQLConnection in project tdq-studio-se by Talend.

the class ConnectionsView method getSelectedConnections.

/**
 * Returns a list of selected sessions; if recurse is true, then it includes indirectly selected sessions (eg a
 * selected user's sessions)
 *
 * @param recurse
 * @return Set of Sessions, never returns null
 */
public Set<SQLConnection> getSelectedConnections(boolean recurse) {
    IStructuredSelection selection = (IStructuredSelection) _treeViewer.getSelection();
    if (selection == null) {
        return EMPTY_CONNECTIONS;
    }
    LinkedHashSet<SQLConnection> result = new LinkedHashSet<SQLConnection>();
    Iterator iter = selection.iterator();
    while (iter.hasNext()) {
        Object obj = iter.next();
        if (obj instanceof SQLConnection) {
            result.add((SQLConnection) obj);
        } else if (recurse) {
            if (obj instanceof Alias) {
                Alias alias = (Alias) obj;
                for (User user : alias.getUsers()) {
                    result.addAll(user.getConnections());
                }
            } else if (obj instanceof User) {
                User user = (User) obj;
                result.addAll(user.getConnections());
            }
        }
    }
    return result;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) User(net.sourceforge.sqlexplorer.dbproduct.User) Alias(net.sourceforge.sqlexplorer.dbproduct.Alias) SQLConnection(net.sourceforge.sqlexplorer.dbproduct.SQLConnection) Iterator(java.util.Iterator) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection)

Example 4 with SQLConnection

use of net.sourceforge.sqlexplorer.dbproduct.SQLConnection in project tdq-studio-se by Talend.

the class ConnectionInfoTab method getDataSet.

public DataSet getDataSet() throws Exception {
    INode node = getNode();
    if (node == null) {
        return null;
    }
    SQLDatabaseMetaData sqlMetaData = node.getSession().getMetaData();
    DatabaseMetaData jdbcMetaData = sqlMetaData.getJDBCMetaData();
    String[] header = new String[2];
    header[0] = Messages.getString("DatabaseDetailView.Tab.ConnectionInfo.Property");
    header[1] = Messages.getString("DatabaseDetailView.Tab.ConnectionInfo.Value");
    String[][] data = new String[124][2];
    SQLConnection connection = node.getSession().grabConnection();
    boolean commitOnClose = false;
    try {
        commitOnClose = connection.getCommitOnClose();
    } finally {
        node.getSession().releaseConnection(connection);
    }
    data[0][0] = Messages.getString("DatabaseDetailView.Tab.ConnectionInfo.DatabaseProductName");
    try {
        data[0][1] = sqlMetaData.getDatabaseProductName();
    } catch (Throwable e) {
    }
    data[1][0] = Messages.getString("DatabaseDetailView.Tab.ConnectionInfo.DriverMajor");
    try {
        data[1][1] = "" + jdbcMetaData.getDriverMajorVersion();
    }// $NON-NLS-1$
     catch (Throwable e) {
    }
    data[2][0] = Messages.getString("DatabaseDetailView.Tab.ConnectionInfo.DriverMinor");
    try {
        data[2][1] = "" + jdbcMetaData.getDriverMinorVersion();
    }// $NON-NLS-1$
     catch (Throwable e) {
    }
    data[3][0] = Messages.getString("DatabaseDetailView.Tab.ConnectionInfo.DriverName");
    try {
        data[3][1] = "" + sqlMetaData.getDriverName();
    }// $NON-NLS-1$
     catch (Throwable e) {
    }
    data[4][0] = Messages.getString("DatabaseDetailView.Tab.ConnectionInfo.DriverVersion");
    try {
        data[4][1] = "" + jdbcMetaData.getDriverVersion();
    }// $NON-NLS-1$
     catch (Throwable e) {
    }
    data[5][0] = Messages.getString("DatabaseDetailView.Tab.ConnectionInfo.UserName");
    try {
        data[5][1] = "" + sqlMetaData.getUserName();
    }// $NON-NLS-1$
     catch (Throwable e) {
    }
    data[6][0] = Messages.getString("DatabaseDetailView.Tab.ConnectionInfo.URL");
    try {
        data[6][1] = "" + jdbcMetaData.getURL();
    }// $NON-NLS-1$
     catch (Throwable e) {
    }
    data[7][0] = Messages.getString("DatabaseDetailView.Tab.ConnectionInfo.AutocommitMode");
    try {
        data[7][1] = "" + jdbcMetaData.getConnection().getAutoCommit();
    }// $NON-NLS-1$
     catch (Throwable e) {
    }
    data[8][0] = Messages.getString("DatabaseDetailView.Tab.ConnectionInfo.CommitOnClose");
    // $NON-NLS-1$
    data[8][1] = "" + commitOnClose;
    data[9][0] = Messages.getString("DatabaseDetailView.Tab.ConnectionInfo.ProceduresCallable");
    try {
        data[9][1] = "" + jdbcMetaData.allProceduresAreCallable();
    }// $NON-NLS-1$
     catch (Throwable e) {
    }
    data[10][0] = Messages.getString("DatabaseDetailView.Tab.ConnectionInfo.TablesSelectable");
    try {
        data[10][1] = "" + jdbcMetaData.allTablesAreSelectable();
    }// $NON-NLS-1$
     catch (Throwable e) {
    }
    data[11][0] = Messages.getString("DatabaseDetailView.Tab.ConnectionInfo.NullsSortedHigh");
    try {
        data[11][1] = "" + jdbcMetaData.nullsAreSortedHigh();
    }// $NON-NLS-1$
     catch (Throwable e) {
    }
    data[12][0] = Messages.getString("DatabaseDetailView.Tab.ConnectionInfo.NullsSortedLow");
    try {
        data[12][1] = "" + jdbcMetaData.nullsAreSortedLow();
    }// $NON-NLS-1$
     catch (Throwable e) {
    }
    data[13][0] = Messages.getString("DatabaseDetailView.Tab.ConnectionInfo.NullsSortedStart");
    try {
        data[13][1] = "" + jdbcMetaData.nullsAreSortedAtStart();
    }// $NON-NLS-1$
     catch (Throwable e) {
    }
    data[14][0] = Messages.getString("DatabaseDetailView.Tab.ConnectionInfo.NullsSortedEnd");
    try {
        data[14][1] = "" + jdbcMetaData.nullsAreSortedAtEnd();
    }// $NON-NLS-1$
     catch (Throwable e) {
    }
    data[15][0] = Messages.getString("ConnectionInfoTab.data[15]");
    try {
        data[15][1] = "" + jdbcMetaData.getResultSetHoldability();
    }// $NON-NLS-1$
     catch (Throwable e) {
    }
    data[16][0] = Messages.getString("ConnectionInfoTab.data[16]");
    try {
        data[16][1] = "" + jdbcMetaData.usesLocalFiles();
    }// $NON-NLS-1$
     catch (Throwable e) {
    }
    data[17][0] = Messages.getString("ConnectionInfoTab.data[17]");
    try {
        data[17][1] = "" + jdbcMetaData.usesLocalFilePerTable();
    }// $NON-NLS-1$
     catch (Throwable e) {
    }
    data[18][0] = Messages.getString("ConnectionInfoTab.data[18]");
    try {
        data[18][1] = "" + jdbcMetaData.supportsMixedCaseIdentifiers();
    }// $NON-NLS-1$
     catch (Throwable e) {
    }
    data[19][0] = Messages.getString("ConnectionInfoTab.data[19]");
    try {
        data[19][1] = "" + jdbcMetaData.storesUpperCaseIdentifiers();
    }// $NON-NLS-1$
     catch (Throwable e) {
    }
    data[20][0] = Messages.getString("ConnectionInfoTab.data[20]");
    // $NON-NLS-1$
    try {
        data[20][1] = "" + jdbcMetaData.storesLowerCaseIdentifiers();
    } catch (Throwable e) {
    }
    data[21][0] = Messages.getString("ConnectionInfoTab.data[21]");
    // $NON-NLS-1$
    try {
        data[21][1] = "" + jdbcMetaData.storesMixedCaseIdentifiers();
    } catch (Throwable e) {
    }
    data[22][0] = Messages.getString("ConnectionInfoTab.data[22]");
    // $NON-NLS-1$
    try {
        data[22][1] = "" + jdbcMetaData.supportsMixedCaseQuotedIdentifiers();
    } catch (Throwable e) {
    }
    data[23][0] = Messages.getString("ConnectionInfoTab.data[23]");
    // $NON-NLS-1$
    try {
        data[23][1] = "" + jdbcMetaData.storesUpperCaseQuotedIdentifiers();
    } catch (Throwable e) {
    }
    data[24][0] = Messages.getString("ConnectionInfoTab.data[24]");
    // $NON-NLS-1$
    try {
        data[24][1] = "" + jdbcMetaData.storesLowerCaseQuotedIdentifiers();
    } catch (Throwable e) {
    }
    data[25][0] = Messages.getString("ConnectionInfoTab.data[25]");
    // $NON-NLS-1$
    try {
        data[25][1] = "" + jdbcMetaData.storesMixedCaseQuotedIdentifiers();
    } catch (Throwable e) {
    }
    data[26][0] = Messages.getString("ConnectionInfoTab.data[26]");
    // $NON-NLS-1$
    try {
        data[26][1] = "" + jdbcMetaData.getIdentifierQuoteString();
    } catch (Throwable e) {
    }
    data[27][0] = Messages.getString("ConnectionInfoTab.data[27]");
    // $NON-NLS-1$
    try {
        data[27][1] = "" + jdbcMetaData.getSearchStringEscape();
    } catch (Throwable e) {
    }
    data[28][0] = Messages.getString("ConnectionInfoTab.data[28]");
    // $NON-NLS-1$
    try {
        data[28][1] = "" + jdbcMetaData.getExtraNameCharacters();
    } catch (Throwable e) {
    }
    data[29][0] = Messages.getString("ConnectionInfoTab.data[29]");
    try {
        // $NON-NLS-1$
        data[29][1] = "" + jdbcMetaData.supportsAlterTableWithAddColumn();
    } catch (Throwable e) {
    }
    data[30][0] = Messages.getString("ConnectionInfoTab.data[30]");
    try {
        // $NON-NLS-1$
        data[30][1] = "" + jdbcMetaData.supportsAlterTableWithDropColumn();
    } catch (Throwable e) {
    }
    data[31][0] = Messages.getString("ConnectionInfoTab.data[31]");
    try {
        // $NON-NLS-1$
        data[31][1] = "" + jdbcMetaData.supportsColumnAliasing();
    } catch (Throwable e) {
    }
    data[32][0] = Messages.getString("ConnectionInfoTab.data[32]");
    try {
        // $NON-NLS-1$
        data[32][1] = "" + jdbcMetaData.nullPlusNonNullIsNull();
    } catch (Throwable e) {
    }
    data[33][0] = Messages.getString("ConnectionInfoTab.data[33]");
    try {
        // $NON-NLS-1$
        data[33][1] = "" + jdbcMetaData.supportsConvert();
    } catch (Throwable e) {
    }
    data[34][0] = Messages.getString("ConnectionInfoTab.data[34]");
    try {
        // $NON-NLS-1$
        data[34][1] = "" + jdbcMetaData.supportsTableCorrelationNames();
    } catch (Throwable e) {
    }
    data[35][0] = Messages.getString("ConnectionInfoTab.data[35]");
    try {
        // $NON-NLS-1$
        data[35][1] = "" + jdbcMetaData.supportsDifferentTableCorrelationNames();
    } catch (Throwable e) {
    }
    data[36][0] = Messages.getString("ConnectionInfoTab.data[36]");
    try {
        data[36][1] = "" + jdbcMetaData.supportsExpressionsInOrderBy();
    }// $NON-NLS-1$
     catch (Throwable e) {
    }
    data[37][0] = Messages.getString("ConnectionInfoTab.data[37]");
    try {
        data[37][1] = "" + jdbcMetaData.supportsOrderByUnrelated();
    }// $NON-NLS-1$
     catch (Throwable e) {
    }
    data[38][0] = Messages.getString("ConnectionInfoTab.data[38]");
    try {
        data[38][1] = "" + jdbcMetaData.supportsGroupBy();
    }// $NON-NLS-1$
     catch (Throwable e) {
    }
    data[39][0] = Messages.getString("ConnectionInfoTab.data[39]");
    try {
        data[39][1] = "" + jdbcMetaData.supportsGroupByUnrelated();
    }// $NON-NLS-1$
     catch (Throwable e) {
    }
    data[40][0] = Messages.getString("ConnectionInfoTab.data[40]");
    try {
        data[40][1] = "" + jdbcMetaData.supportsGroupByBeyondSelect();
    }// $NON-NLS-1$
     catch (Throwable e) {
    }
    data[41][0] = Messages.getString("ConnectionInfoTab.data[41]");
    try {
        data[41][1] = "" + jdbcMetaData.supportsLikeEscapeClause();
    }// $NON-NLS-1$
     catch (Throwable e) {
    }
    data[42][0] = Messages.getString("ConnectionInfoTab.data[42]");
    try {
        data[42][1] = "" + jdbcMetaData.supportsMultipleResultSets();
    }// $NON-NLS-1$
     catch (Throwable e) {
    }
    data[43][0] = Messages.getString("ConnectionInfoTab.data[43]");
    try {
        data[43][1] = "" + jdbcMetaData.supportsMultipleOpenResults();
    }// $NON-NLS-1$
     catch (Throwable e) {
    }
    data[44][0] = Messages.getString("ConnectionInfoTab.data[44]");
    try {
        data[44][1] = "" + jdbcMetaData.supportsMultipleTransactions();
    }// $NON-NLS-1$
     catch (Throwable e) {
    }
    data[45][0] = Messages.getString("ConnectionInfoTab.data[45]");
    try {
        data[45][1] = "" + jdbcMetaData.supportsNonNullableColumns();
    }// $NON-NLS-1$
     catch (Throwable e) {
    }
    data[46][0] = Messages.getString("ConnectionInfoTab.data[46]");
    try {
        data[46][1] = "" + jdbcMetaData.supportsMinimumSQLGrammar();
    }// $NON-NLS-1$
     catch (Throwable e) {
    }
    data[47][0] = Messages.getString("ConnectionInfoTab.data[47]");
    try {
        data[47][1] = "" + jdbcMetaData.supportsCoreSQLGrammar();
    }// $NON-NLS-1$
     catch (Throwable e) {
    }
    data[48][0] = Messages.getString("ConnectionInfoTab.data[48]");
    try {
        data[48][1] = "" + jdbcMetaData.supportsExtendedSQLGrammar();
    }// $NON-NLS-1$
     catch (Throwable e) {
    }
    data[49][0] = Messages.getString("ConnectionInfoTab.data[49]");
    try {
        data[49][1] = "" + jdbcMetaData.supportsANSI92EntryLevelSQL();
    }// $NON-NLS-1$
     catch (Throwable e) {
    }
    data[50][0] = Messages.getString("ConnectionInfoTab.data[50]");
    try {
        data[50][1] = "" + jdbcMetaData.supportsANSI92IntermediateSQL();
    }// $NON-NLS-1$
     catch (Throwable e) {
    }
    data[51][0] = Messages.getString("ConnectionInfoTab.data[51]");
    try {
        data[51][1] = "" + jdbcMetaData.supportsANSI92FullSQL();
    }// $NON-NLS-1$
     catch (Throwable e) {
    }
    data[52][0] = Messages.getString("ConnectionInfoTab.data[52]");
    try {
        data[52][1] = "" + jdbcMetaData.supportsIntegrityEnhancementFacility();
    }// $NON-NLS-1$
     catch (Throwable e) {
    }
    data[53][0] = Messages.getString("ConnectionInfoTab.data[53]");
    try {
        data[53][1] = "" + jdbcMetaData.supportsOuterJoins();
    }// $NON-NLS-1$
     catch (Throwable e) {
    }
    data[54][0] = Messages.getString("ConnectionInfoTab.data[54]");
    try {
        data[54][1] = "" + jdbcMetaData.supportsFullOuterJoins();
    }// $NON-NLS-1$
     catch (Throwable e) {
    }
    data[55][0] = Messages.getString("ConnectionInfoTab.data[55]");
    try {
        data[55][1] = "" + jdbcMetaData.supportsLimitedOuterJoins();
    }// $NON-NLS-1$
     catch (Throwable e) {
    }
    data[56][0] = Messages.getString("ConnectionInfoTab.data[56]");
    try {
        data[56][1] = "" + jdbcMetaData.getSchemaTerm();
    }// $NON-NLS-1$
     catch (Throwable e) {
    }
    data[57][0] = Messages.getString("ConnectionInfoTab.data[57]");
    try {
        data[57][1] = "" + jdbcMetaData.getProcedureTerm();
    }// $NON-NLS-1$
     catch (Throwable e) {
    }
    data[58][0] = Messages.getString("ConnectionInfoTab.data[58]");
    try {
        data[58][1] = "" + jdbcMetaData.getCatalogTerm();
    }// $NON-NLS-1$
     catch (Throwable e) {
    }
    data[59][0] = Messages.getString("ConnectionInfoTab.data[59]");
    try {
        data[59][1] = "" + jdbcMetaData.isCatalogAtStart();
    }// $NON-NLS-1$
     catch (Throwable e) {
    }
    data[60][0] = Messages.getString("ConnectionInfoTab.data[60]");
    try {
        data[60][1] = "" + jdbcMetaData.getCatalogSeparator();
    }// $NON-NLS-1$
     catch (Throwable e) {
    }
    data[61][0] = Messages.getString("ConnectionInfoTab.data[61]");
    try {
        data[61][1] = "" + jdbcMetaData.supportsSchemasInDataManipulation();
    }// $NON-NLS-1$
     catch (Throwable e) {
    }
    data[62][0] = Messages.getString("ConnectionInfoTab.data[62]");
    try {
        data[62][1] = "" + jdbcMetaData.supportsSchemasInProcedureCalls();
    }// $NON-NLS-1$
     catch (Throwable e) {
    }
    data[63][0] = Messages.getString("ConnectionInfoTab.data[63]");
    try {
        data[63][1] = "" + jdbcMetaData.supportsSchemasInTableDefinitions();
    }// $NON-NLS-1$
     catch (Throwable e) {
    }
    data[64][0] = Messages.getString("ConnectionInfoTab.data[64]");
    try {
        data[64][1] = "" + jdbcMetaData.supportsSchemasInIndexDefinitions();
    }// $NON-NLS-1$
     catch (Throwable e) {
    }
    data[65][0] = Messages.getString("ConnectionInfoTab.data[65]");
    try {
        data[65][1] = "" + jdbcMetaData.supportsSchemasInPrivilegeDefinitions();
    }// $NON-NLS-1$
     catch (Throwable e) {
    }
    data[66][0] = Messages.getString("ConnectionInfoTab.data[66]");
    try {
        data[66][1] = "" + jdbcMetaData.supportsCatalogsInDataManipulation();
    }// $NON-NLS-1$
     catch (Throwable e) {
    }
    data[67][0] = Messages.getString("ConnectionInfoTab.data[67]");
    try {
        data[67][1] = "" + jdbcMetaData.supportsCatalogsInProcedureCalls();
    }// $NON-NLS-1$
     catch (Throwable e) {
    }
    data[68][0] = Messages.getString("ConnectionInfoTab.data[68]");
    try {
        data[68][1] = "" + jdbcMetaData.supportsCatalogsInTableDefinitions();
    }// $NON-NLS-1$
     catch (Throwable e) {
    }
    data[69][0] = Messages.getString("ConnectionInfoTab.data[69]");
    try {
        data[69][1] = "" + jdbcMetaData.supportsCatalogsInIndexDefinitions();
    }// $NON-NLS-1$
     catch (Throwable e) {
    }
    data[70][0] = Messages.getString("ConnectionInfoTab.data[70]");
    try {
        data[70][1] = "" + jdbcMetaData.supportsCatalogsInPrivilegeDefinitions();
    }// $NON-NLS-1$
     catch (Throwable e) {
    }
    data[71][0] = Messages.getString("ConnectionInfoTab.data[71]");
    try {
        data[71][1] = "" + jdbcMetaData.supportsPositionedDelete();
    }// $NON-NLS-1$
     catch (Throwable e) {
    }
    data[72][0] = Messages.getString("ConnectionInfoTab.data[72]");
    try {
        data[72][1] = "" + jdbcMetaData.supportsPositionedUpdate();
    }// $NON-NLS-1$
     catch (Throwable e) {
    }
    data[73][0] = Messages.getString("ConnectionInfoTab.data[73]");
    try {
        data[73][1] = "" + jdbcMetaData.supportsStoredProcedures();
    }// $NON-NLS-1$
     catch (Throwable e) {
    }
    data[74][0] = Messages.getString("ConnectionInfoTab.data[74]");
    try {
        data[74][1] = "" + jdbcMetaData.supportsSubqueriesInComparisons();
    }// $NON-NLS-1$
     catch (Throwable e) {
    }
    data[75][0] = Messages.getString("ConnectionInfoTab.data[75]");
    try {
        data[75][1] = "" + jdbcMetaData.supportsSubqueriesInExists();
    }// $NON-NLS-1$
     catch (Throwable e) {
    }
    data[76][0] = Messages.getString("ConnectionInfoTab.data[76]");
    try {
        data[76][1] = "" + jdbcMetaData.supportsSubqueriesInIns();
    }// $NON-NLS-1$
     catch (Throwable e) {
    }
    data[77][0] = Messages.getString("ConnectionInfoTab.data[77]");
    try {
        data[77][1] = "" + jdbcMetaData.supportsSubqueriesInQuantifieds();
    }// $NON-NLS-1$
     catch (Throwable e) {
    }
    data[78][0] = Messages.getString("ConnectionInfoTab.data[78]");
    try {
        data[78][1] = "" + jdbcMetaData.supportsCorrelatedSubqueries();
    }// $NON-NLS-1$
     catch (Throwable e) {
    }
    data[79][0] = Messages.getString("ConnectionInfoTab.data[79]");
    try {
        data[79][1] = "" + jdbcMetaData.supportsUnion();
    }// $NON-NLS-1$
     catch (Throwable e) {
    }
    data[80][0] = Messages.getString("ConnectionInfoTab.data[80]");
    try {
        data[80][1] = "" + jdbcMetaData.supportsUnionAll();
    }// $NON-NLS-1$
     catch (Throwable e) {
    }
    data[81][0] = Messages.getString("ConnectionInfoTab.data[81]");
    try {
        data[81][1] = "" + jdbcMetaData.supportsOpenCursorsAcrossCommit();
    }// $NON-NLS-1$
     catch (Throwable e) {
    }
    data[82][0] = Messages.getString("ConnectionInfoTab.data[82]");
    try {
        data[82][1] = "" + jdbcMetaData.supportsOpenCursorsAcrossRollback();
    }// $NON-NLS-1$
     catch (Throwable e) {
    }
    data[83][0] = Messages.getString("ConnectionInfoTab.data[83]");
    try {
        data[83][1] = "" + jdbcMetaData.supportsOpenStatementsAcrossCommit();
    }// $NON-NLS-1$
     catch (Throwable e) {
    }
    data[84][0] = Messages.getString("ConnectionInfoTab.data[84]");
    try {
        data[84][1] = "" + jdbcMetaData.supportsOpenStatementsAcrossRollback();
    }// $NON-NLS-1$
     catch (Throwable e) {
    }
    data[85][0] = Messages.getString("ConnectionInfoTab.data[85]");
    try {
        data[85][1] = "" + jdbcMetaData.getMaxBinaryLiteralLength();
    }// $NON-NLS-1$
     catch (Throwable e) {
    }
    data[86][0] = Messages.getString("ConnectionInfoTab.data[86]");
    try {
        data[86][1] = "" + jdbcMetaData.getMaxCharLiteralLength();
    }// $NON-NLS-1$
     catch (Throwable e) {
    }
    data[87][0] = Messages.getString("ConnectionInfoTab.data[87]");
    try {
        data[87][1] = "" + jdbcMetaData.getMaxColumnNameLength();
    }// $NON-NLS-1$
     catch (Throwable e) {
    }
    data[88][0] = Messages.getString("ConnectionInfoTab.data[88]");
    try {
        data[88][1] = "" + jdbcMetaData.getMaxColumnsInGroupBy();
    }// $NON-NLS-1$
     catch (Throwable e) {
    }
    data[89][0] = Messages.getString("ConnectionInfoTab.data[89]");
    try {
        data[89][1] = "" + jdbcMetaData.getMaxColumnsInIndex();
    }// $NON-NLS-1$
     catch (Throwable e) {
    }
    data[90][0] = Messages.getString("ConnectionInfoTab.data[90]");
    try {
        data[90][1] = "" + jdbcMetaData.getMaxColumnsInOrderBy();
    }// $NON-NLS-1$
     catch (Throwable e) {
    }
    data[91][0] = Messages.getString("ConnectionInfoTab.data[91]");
    try {
        data[91][1] = "" + jdbcMetaData.getMaxColumnsInSelect();
    }// $NON-NLS-1$
     catch (Throwable e) {
    }
    data[92][0] = Messages.getString("ConnectionInfoTab.data[92]");
    try {
        data[92][1] = "" + jdbcMetaData.getMaxColumnsInTable();
    }// $NON-NLS-1$
     catch (Throwable e) {
    }
    data[93][0] = Messages.getString("ConnectionInfoTab.data[93]");
    try {
        data[93][1] = "" + jdbcMetaData.getMaxConnections();
    }// $NON-NLS-1$
     catch (Throwable e) {
    }
    data[94][0] = Messages.getString("ConnectionInfoTab.data[94]");
    try {
        data[94][1] = "" + jdbcMetaData.getMaxCursorNameLength();
    }// $NON-NLS-1$
     catch (Throwable e) {
    }
    data[95][0] = Messages.getString("ConnectionInfoTab.data[95]");
    try {
        data[95][1] = "" + jdbcMetaData.getMaxIndexLength();
    }// $NON-NLS-1$
     catch (Throwable e) {
    }
    data[96][0] = Messages.getString("ConnectionInfoTab.data[96]");
    try {
        data[96][1] = "" + jdbcMetaData.getMaxSchemaNameLength();
    }// $NON-NLS-1$
     catch (Throwable e) {
    }
    data[97][0] = Messages.getString("ConnectionInfoTab.data[97]");
    try {
        data[97][1] = "" + jdbcMetaData.getMaxProcedureNameLength();
    }// $NON-NLS-1$
     catch (Throwable e) {
    }
    data[98][0] = Messages.getString("ConnectionInfoTab.data[98]");
    try {
        data[98][1] = "" + jdbcMetaData.getMaxCatalogNameLength();
    }// $NON-NLS-1$
     catch (Throwable e) {
    }
    data[99][0] = Messages.getString("ConnectionInfoTab.data[99]");
    try {
        data[99][1] = "" + jdbcMetaData.getMaxRowSize();
    }// $NON-NLS-1$
     catch (Throwable e) {
    }
    data[100][0] = Messages.getString("ConnectionInfoTab.data[100]");
    try {
        data[100][1] = "" + jdbcMetaData.doesMaxRowSizeIncludeBlobs();
    }// $NON-NLS-1$
     catch (Throwable e) {
    }
    data[101][0] = Messages.getString("ConnectionInfoTab.data[101]");
    try {
        data[101][1] = "" + jdbcMetaData.getMaxStatementLength();
    }// $NON-NLS-1$
     catch (Throwable e) {
    }
    data[102][0] = Messages.getString("ConnectionInfoTab.data[102]");
    try {
        data[102][1] = "" + jdbcMetaData.getMaxStatements();
    }// $NON-NLS-1$
     catch (Throwable e) {
    }
    data[103][0] = Messages.getString("ConnectionInfoTab.data[103]");
    try {
        data[103][1] = "" + jdbcMetaData.getMaxTableNameLength();
    }// $NON-NLS-1$
     catch (Throwable e) {
    }
    data[104][0] = Messages.getString("ConnectionInfoTab.data[104]");
    try {
        data[104][1] = "" + jdbcMetaData.getMaxTablesInSelect();
    }// $NON-NLS-1$
     catch (Throwable e) {
    }
    data[105][0] = Messages.getString("ConnectionInfoTab.data[105]");
    try {
        data[105][1] = "" + jdbcMetaData.getMaxUserNameLength();
    }// $NON-NLS-1$
     catch (Throwable e) {
    }
    data[106][0] = Messages.getString("ConnectionInfoTab.data[106]");
    try {
        int isol = jdbcMetaData.getDefaultTransactionIsolation();
        String is = null;
        switch(isol) {
            case java.sql.Connection.TRANSACTION_NONE:
                // $NON-NLS-1$
                is = "TRANSACTION_NONE";
                break;
            case java.sql.Connection.TRANSACTION_READ_COMMITTED:
                // $NON-NLS-1$
                is = "TRANSACTION_READ_COMMITTED";
                break;
            case java.sql.Connection.TRANSACTION_READ_UNCOMMITTED:
                // $NON-NLS-1$
                is = "TRANSACTION_READ_UNCOMMITTED";
                break;
            case java.sql.Connection.TRANSACTION_REPEATABLE_READ:
                // $NON-NLS-1$
                is = "TRANSACTION_REPEATABLE_READ";
                break;
            case java.sql.Connection.TRANSACTION_SERIALIZABLE:
                // $NON-NLS-1$
                is = "TRANSACTION_SERIALIZABLE";
                break;
            default:
                // $NON-NLS-1$
                is = "";
                break;
        }
        data[106][1] = is;
    } catch (Throwable e) {
    }
    data[107][0] = Messages.getString("ConnectionInfoTab.data[107]");
    try {
        data[107][1] = "" + jdbcMetaData.supportsTransactions();
    }// $NON-NLS-1$
     catch (Throwable e) {
    }
    data[108][0] = Messages.getString("ConnectionInfoTab.data[108]");
    try {
        data[108][1] = "" + jdbcMetaData.supportsDataDefinitionAndDataManipulationTransactions();
    }// $NON-NLS-1$
     catch (Throwable e) {
    }
    data[109][0] = Messages.getString("ConnectionInfoTab.data[109]");
    try {
        data[109][1] = "" + jdbcMetaData.supportsDataManipulationTransactionsOnly();
    }// $NON-NLS-1$
     catch (Throwable e) {
    }
    data[110][0] = Messages.getString("ConnectionInfoTab.data[110]");
    try {
        data[110][1] = "" + jdbcMetaData.dataDefinitionCausesTransactionCommit();
    }// $NON-NLS-1$
     catch (Throwable e) {
    }
    data[111][0] = Messages.getString("ConnectionInfoTab.data[111]");
    try {
        data[111][1] = "" + jdbcMetaData.dataDefinitionIgnoredInTransactions();
    }// $NON-NLS-1$
     catch (Throwable e) {
    }
    data[112][0] = Messages.getString("ConnectionInfoTab.data[112]");
    try {
        data[112][1] = "" + jdbcMetaData.supportsBatchUpdates();
    }// $NON-NLS-1$
     catch (Throwable e) {
    }
    data[113][0] = Messages.getString("ConnectionInfoTab.data[113]");
    try {
        data[113][1] = "" + jdbcMetaData.supportsSavepoints();
    }// $NON-NLS-1$
     catch (Throwable e) {
    }
    data[114][0] = Messages.getString("ConnectionInfoTab.data[114]");
    try {
        data[114][1] = "" + jdbcMetaData.supportsNamedParameters();
    }// $NON-NLS-1$
     catch (Throwable e) {
    }
    data[115][0] = Messages.getString("ConnectionInfoTab.data[115]");
    try {
        data[115][1] = "" + jdbcMetaData.supportsGetGeneratedKeys();
    }// $NON-NLS-1$
     catch (Throwable e) {
    }
    data[116][0] = Messages.getString("ConnectionInfoTab.data[116]");
    try {
        data[116][1] = "" + jdbcMetaData.getDatabaseMajorVersion();
    }// $NON-NLS-1$
     catch (Throwable e) {
    }
    data[117][0] = Messages.getString("ConnectionInfoTab.data[117]");
    try {
        data[117][1] = "" + jdbcMetaData.getDatabaseMinorVersion();
    }// $NON-NLS-1$
     catch (Throwable e) {
    }
    data[118][0] = Messages.getString("ConnectionInfoTab.data[118]");
    try {
        data[118][1] = "" + jdbcMetaData.getJDBCMinorVersion();
    }// $NON-NLS-1$
     catch (Throwable e) {
    }
    data[119][0] = Messages.getString("ConnectionInfoTab.data[119]");
    try {
        data[119][1] = "" + jdbcMetaData.getJDBCMajorVersion();
    }// $NON-NLS-1$
     catch (Throwable e) {
    }
    data[120][0] = Messages.getString("ConnectionInfoTab.data[120]");
    try {
        data[120][1] = "" + jdbcMetaData.getSQLStateType();
    }// $NON-NLS-1$
     catch (Throwable e) {
    }
    data[121][0] = Messages.getString("ConnectionInfoTab.data[121]");
    try {
        data[121][1] = "" + jdbcMetaData.locatorsUpdateCopy();
    }// $NON-NLS-1$
     catch (Throwable e) {
    }
    data[122][0] = Messages.getString("ConnectionInfoTab.data[122]");
    try {
        data[122][1] = "" + jdbcMetaData.supportsStatementPooling();
    }// $NON-NLS-1$
     catch (Throwable e) {
    }
    data[123][0] = Messages.getString("DatabaseDetailView.Tab.ConnectionInfo.ReadOnly");
    try {
        data[123][1] = "" + jdbcMetaData.isReadOnly();
    }// $NON-NLS-1$
     catch (Throwable e) {
    }
    DataSet dataSet = new DataSet(header, data);
    return dataSet;
}
Also used : INode(net.sourceforge.sqlexplorer.dbstructure.nodes.INode) SQLDatabaseMetaData(net.sourceforge.squirrel_sql.fw.sql.SQLDatabaseMetaData) DataSet(net.sourceforge.sqlexplorer.dataset.DataSet) SQLConnection(net.sourceforge.sqlexplorer.dbproduct.SQLConnection) SQLDatabaseMetaData(net.sourceforge.squirrel_sql.fw.sql.SQLDatabaseMetaData) DatabaseMetaData(java.sql.DatabaseMetaData)

Example 5 with SQLConnection

use of net.sourceforge.sqlexplorer.dbproduct.SQLConnection in project tdq-studio-se by Talend.

the class AbstractSQLTab method getDataSet.

public final DataSet getDataSet() throws Exception {
    DataSet dataSet = null;
    int timeOut = SQLExplorerPlugin.getDefault().getPluginPreferences().getInt(IConstants.INTERACTIVE_QUERY_TIMEOUT);
    SQLConnection connection = null;
    ResultSet rs = null;
    Statement stmt = null;
    PreparedStatement pStmt = null;
    try {
        connection = getNode().getSession().grabConnection();
        Object[] params = getSQLParameters();
        if (params == null || params.length == 0) {
            // use normal statement
            stmt = connection.createStatement();
            stmt.setQueryTimeout(timeOut);
            rs = stmt.executeQuery(getSQL());
        } else {
            // use prepared statement
            pStmt = connection.prepareStatement(getSQL());
            pStmt.setQueryTimeout(timeOut);
            for (int i = 0; i < params.length; i++) {
                if (params[i] instanceof String) {
                    pStmt.setString(i + 1, (String) params[i]);
                } else if (params[i] instanceof Integer) {
                    pStmt.setInt(i + 1, ((Integer) params[i]).intValue());
                } else if (params[i] instanceof String) {
                    pStmt.setLong(i + 1, ((Long) params[i]).longValue());
                }
            }
            rs = pStmt.executeQuery();
        }
        dataSet = new DataSet(rs, null);
        rs.close();
        rs = null;
    } catch (Exception e) {
        SQLExplorerPlugin.error(Messages.getString("AbstractSQLSourceTab.cannotLoadSource") + getNode().getName(), e);
    } finally {
        if (rs != null)
            try {
                rs.close();
            } catch (SQLException e) {
                SQLExplorerPlugin.error(Messages.getString("DataSet.errorCloseRs"), e);
            }
        if (stmt != null)
            try {
                stmt.close();
            } catch (SQLException e) {
                SQLExplorerPlugin.error(Messages.getString("DataSet.errorCloseStmt"), e);
            }
        if (pStmt != null)
            try {
                pStmt.close();
            } catch (SQLException e) {
                SQLExplorerPlugin.error(Messages.getString("DataSet.errorCloseStmt"), e);
            }
        if (connection != null)
            getNode().getSession().releaseConnection(connection);
    }
    return dataSet;
}
Also used : DataSet(net.sourceforge.sqlexplorer.dataset.DataSet) SQLException(java.sql.SQLException) Statement(java.sql.Statement) PreparedStatement(java.sql.PreparedStatement) SQLConnection(net.sourceforge.sqlexplorer.dbproduct.SQLConnection) ResultSet(java.sql.ResultSet) PreparedStatement(java.sql.PreparedStatement) SQLException(java.sql.SQLException)

Aggregations

SQLConnection (net.sourceforge.sqlexplorer.dbproduct.SQLConnection)17 SQLException (java.sql.SQLException)7 User (net.sourceforge.sqlexplorer.dbproduct.User)7 Alias (net.sourceforge.sqlexplorer.dbproduct.Alias)6 ResultSet (java.sql.ResultSet)5 Statement (java.sql.Statement)5 DataSet (net.sourceforge.sqlexplorer.dataset.DataSet)4 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)4 PreparedStatement (java.sql.PreparedStatement)3 Iterator (java.util.Iterator)3 LinkedHashSet (java.util.LinkedHashSet)3 Session (net.sourceforge.sqlexplorer.dbproduct.Session)3 INode (net.sourceforge.sqlexplorer.dbstructure.nodes.INode)2 ParserException (net.sourceforge.sqlexplorer.parsers.ParserException)2 QueryParser (net.sourceforge.sqlexplorer.parsers.QueryParser)2 MessageDialogWithToggle (org.eclipse.jface.dialogs.MessageDialogWithToggle)2 File (java.io.File)1 FileReader (java.io.FileReader)1 IOException (java.io.IOException)1 DatabaseMetaData (java.sql.DatabaseMetaData)1