Search in sources :

Example 1 with SQLDatabaseMetaData

use of net.sourceforge.squirrel_sql.fw.sql.SQLDatabaseMetaData in project tdq-studio-se by Talend.

the class SchemaNode method loadChildren.

/*
     * (non-Javadoc)
     * 
     * @see net.sourceforge.sqlexplorer.dbstructure.nodes.AbstractNode#loadChildren()
     */
public void loadChildren() {
    _childNames = new ArrayList();
    try {
        ITableInfo[] tables = null;
        String[] tableTypes = _session.getMetaData().getTableTypes();
        try {
            // MOD qiongli 2012-8-22 TDQ-5898,get tables should without catalog name for odbc teradata.
            SQLDatabaseMetaData metaData = _session.getMetaData();
            boolean isODBCTeradata = ConnectionUtils.isOdbcTeradata(metaData.getJDBCMetaData());
            boolean isNetezza = ConnectionUtils.isNetezza(metaData.getJDBCMetaData());
            if (isODBCTeradata || isNetezza) {
                tables = metaData.getTables(null, _name, "%", tableTypes, null);
            } else {
                tables = metaData.getTables(_name, _name, "%", tableTypes, null);
            }
        } catch (Throwable e) {
            _logger.debug("Loading all tables at once is not supported");
        }
        for (int i = 0; i < tableTypes.length; ++i) {
            INode childNode = findExtensionNode(tableTypes[i]);
            if (childNode != null) {
                _childNames.add(childNode.getLabelText());
                if (!isExcludedByFilter(childNode.getLabelText())) {
                    addChildNode(childNode);
                }
            } else {
                if (tables != null) {
                    TableFolderNode node = new TableFolderNode(this, tableTypes[i], _session, tables);
                    _childNames.add(node.getLabelText());
                    if (!isExcludedByFilter(node.getLabelText())) {
                        addChildNode(node);
                    }
                }
            }
        }
        // load extension nodes
        addExtensionNodes();
    } catch (Throwable e) {
        SQLExplorerPlugin.error("Could not load child nodes for " + _name, e);
    }
}
Also used : SQLDatabaseMetaData(net.sourceforge.squirrel_sql.fw.sql.SQLDatabaseMetaData) ITableInfo(net.sourceforge.squirrel_sql.fw.sql.ITableInfo) ArrayList(java.util.ArrayList) IExtensionPoint(org.eclipse.core.runtime.IExtensionPoint)

Example 2 with SQLDatabaseMetaData

use of net.sourceforge.squirrel_sql.fw.sql.SQLDatabaseMetaData 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 3 with SQLDatabaseMetaData

use of net.sourceforge.squirrel_sql.fw.sql.SQLDatabaseMetaData in project tdi-studio-se by Talend.

the class ConnectionInfoTab method getDataSet.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.sqlbuilder.dbdetail.tab.AbstractDataSetTab#getDataSet()
     */
@Override
public DataSet getDataSet() throws Exception {
    INode node = getNode();
    if (node == null) {
        return null;
    }
    if (node.getSession() == null) {
        return null;
    }
    SQLDatabaseMetaData sqlMetaData = node.getSession().getMetaData();
    if (sqlMetaData == null) {
        return null;
    }
    DatabaseMetaData jdbcMetaData = sqlMetaData.getJDBCMetaData();
    String[] header = new String[2];
    //$NON-NLS-1$
    header[0] = Messages.getString("DatabaseDetailView.Tab.ConnectionInfo.Property");
    //$NON-NLS-1$
    header[1] = Messages.getString("DatabaseDetailView.Tab.ConnectionInfo.Value");
    String[][] data = new String[124][2];
    setDataTo20(node, sqlMetaData, jdbcMetaData, data);
    setDataTo40(jdbcMetaData, data);
    setDataTo60(jdbcMetaData, data);
    setDataTo80(jdbcMetaData, data);
    setDataTo100(jdbcMetaData, data);
    setDataTo120(jdbcMetaData, data);
    int[] types = new int[2];
    types[0] = DataSet.TYPE_STRING;
    types[1] = DataSet.TYPE_STRING;
    DataSet dataSet = new DataSet(header, data, types);
    return dataSet;
}
Also used : INode(org.talend.sqlbuilder.dbstructure.nodes.INode) SQLDatabaseMetaData(net.sourceforge.squirrel_sql.fw.sql.SQLDatabaseMetaData) DataSet(org.talend.sqlbuilder.dataset.dataset.DataSet) SQLDatabaseMetaData(net.sourceforge.squirrel_sql.fw.sql.SQLDatabaseMetaData) DatabaseMetaData(java.sql.DatabaseMetaData)

Example 4 with SQLDatabaseMetaData

use of net.sourceforge.squirrel_sql.fw.sql.SQLDatabaseMetaData in project tdq-studio-se by Talend.

the class CreateTableScriptAction method run.

/**
 * Create table script for selected node.
 *
 * @see org.eclipse.jface.action.IAction#run()
 */
public void run() {
    TableNode tableNode = (TableNode) _selectedNodes[0];
    ITableInfo info = tableNode.getTableInfo();
    StringBuffer buf = new StringBuffer(4 * 1024);
    String sep = System.getProperty("line.separator");
    try {
        SQLDatabaseMetaData metaData = tableNode.getSession().getMetaData();
        ArrayList<String> pks = new ArrayList<String>();
        PrimaryKeyInfo[] pksInfo = metaData.getPrimaryKey(info);
        for (PrimaryKeyInfo pkInfo : pksInfo) pks.add(pkInfo.getColumnName());
        TableColumnInfo[] columnsInfo = metaData.getColumnInfo(info);
        String tableName = _selectedNodes[0].getQualifiedName();
        buf.append("CREATE TABLE ");
        buf.append(tableName);
        buf.append("(");
        for (TableColumnInfo col : columnsInfo) {
            // String columnName = resultSet.getString(4);
            // String typeName = resultSet.getString(6);
            // String columnSize = resultSet.getString(7);
            // String decimalDigits = resultSet.getString(9);
            // String defaultValue = resultSet.getString(13);
            boolean notNull = "NO".equalsIgnoreCase(col.isNullable());
            String sLower = col.getColumnName().toLowerCase();
            buf.append(sep);
            buf.append(col.getColumnName() + " ");
            buf.append(col.getTypeName());
            boolean bNumeric = false;
            if (sLower.equals("numeric") || sLower.equals("number") || sLower.equals("decimal"))
                bNumeric = true;
            if (sLower.indexOf("char") != -1 || sLower.indexOf("int") != -1) {
                buf.append("(");
                buf.append(col.getColumnSize());
                buf.append(")");
            } else if (bNumeric) {
                buf.append("(");
                buf.append(col.getColumnSize());
                if (col.getDecimalDigits() > 0)
                    buf.append(col.getDecimalDigits());
                buf.append(")");
            }
            if (pks.size() == 1 && pks.get(0).equals(col.getColumnName())) {
                buf.append(" PRIMARY KEY");
            }
            String defaultValue = col.getDefaultValue();
            if (defaultValue != null && !defaultValue.equals("")) {
                buf.append(" default ");
                boolean isSystemValue = bNumeric;
                if (defaultValue.equalsIgnoreCase("CURRENT_TIMESTAMP")) {
                    isSystemValue = true;
                }
                if (!isSystemValue)
                    buf.append("'");
                buf.append(defaultValue);
                if (!isSystemValue)
                    buf.append("'");
            }
            if (notNull) {
                buf.append(" not null");
            }
            buf.append(",");
        }
        buf.deleteCharAt(buf.length() - 1);
        buf.append(")" + sep);
        SQLEditorInput input = new SQLEditorInput("SQL Editor (" + SQLExplorerPlugin.getDefault().getEditorSerialNo() + ").sql");
        input.setUser(_selectedNodes[0].getSession().getUser());
        IWorkbenchPage page = SQLExplorerPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage();
        SQLEditor editorPart = (SQLEditor) page.openEditor((IEditorInput) input, "net.sourceforge.sqlexplorer.plugin.editors.SQLEditor");
        editorPart.setText(buf.toString());
    } catch (SQLException e) {
        SQLExplorerPlugin.error("Error creating export script", e);
    } catch (PartInitException e) {
        SQLExplorerPlugin.error("Error creating export script", e);
    }
}
Also used : SQLEditor(net.sourceforge.sqlexplorer.plugin.editors.SQLEditor) SQLDatabaseMetaData(net.sourceforge.squirrel_sql.fw.sql.SQLDatabaseMetaData) ITableInfo(net.sourceforge.squirrel_sql.fw.sql.ITableInfo) SQLException(java.sql.SQLException) ArrayList(java.util.ArrayList) PrimaryKeyInfo(net.sourceforge.squirrel_sql.fw.sql.PrimaryKeyInfo) SQLEditorInput(net.sourceforge.sqlexplorer.plugin.editors.SQLEditorInput) TableNode(net.sourceforge.sqlexplorer.dbstructure.nodes.TableNode) TableColumnInfo(net.sourceforge.squirrel_sql.fw.sql.TableColumnInfo) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) PartInitException(org.eclipse.ui.PartInitException) IEditorInput(org.eclipse.ui.IEditorInput)

Example 5 with SQLDatabaseMetaData

use of net.sourceforge.squirrel_sql.fw.sql.SQLDatabaseMetaData in project tdq-studio-se by Talend.

the class DatabaseNode method loadChildren.

/**
 * Loads childnodes, filtered to a subset of schemas/databases depending on
 * whether a comma separated list of regular expression filters has been
 * set.
 */
public void loadChildren() {
    _childNames = new ArrayList();
    String metaFilterExpression = _session.getUser().getAlias().getSchemaFilterExpression();
    if (metaFilterExpression != null && metaFilterExpression.trim().length() != 0) {
        _filterExpressions = metaFilterExpression.split(",");
    } else {
        _filterExpressions = null;
    }
    try {
        SQLDatabaseMetaData metadata = _session.getMetaData();
        if (_supportsCatalogs) {
            final String[] catalogs = metadata.getCatalogs();
            if (catalogs == null || catalogs.length == 0) {
                if (_supportsSchemas)
                    _supportsCatalogs = false;
            } else {
                _supportsSchemas = false;
                for (int i = 0; i < catalogs.length; ++i) {
                    _childNames.add(catalogs[i]);
                    if (!isExcludedByFilter(catalogs[i])) {
                        addChildNode(new CatalogNode(this, catalogs[i], _session));
                    }
                }
            }
        }
        if (!_supportsCatalogs && _supportsSchemas) {
            final String[] schemas = metadata.getSchemas();
            for (int i = 0; i < schemas.length; ++i) {
                _childNames.add(schemas[i]);
                if (!isExcludedByFilter(schemas[i])) {
                    addChildNode(new SchemaNode(this, schemas[i], _session));
                }
            }
        }
        if (!_supportsCatalogs && !_supportsSchemas) {
            addChildNode(new CatalogNode(this, Messages.getString("NoCatalog_2"), _session));
        }
        // load extension nodes
        String databaseProductName = _databaseProductName.toLowerCase().trim();
        IExtensionRegistry registry = Platform.getExtensionRegistry();
        IExtensionPoint point = registry.getExtensionPoint("net.sourceforge.sqlexplorer", "node");
        IExtension[] extensions = point.getExtensions();
        for (int i = 0; i < extensions.length; i++) {
            IExtension e = extensions[i];
            IConfigurationElement[] ces = e.getConfigurationElements();
            for (int j = 0; j < ces.length; j++) {
                try {
                    // include only nodes that are attachted to the root
                    // node..
                    String parent = ces[j].getAttribute("parent-node");
                    if (!parent.equalsIgnoreCase("root")) {
                        continue;
                    }
                    boolean isValidProduct = false;
                    String[] validProducts = ces[j].getAttribute("database-product-name").split(",");
                    // include only nodes valid for this database
                    for (int k = 0; k < validProducts.length; k++) {
                        String product = validProducts[k].toLowerCase().trim();
                        if (product.length() == 0) {
                            continue;
                        }
                        if (product.equals("*")) {
                            isValidProduct = true;
                            break;
                        }
                        String regex = TextUtil.replaceChar(product, '*', ".*");
                        if (databaseProductName.matches(regex)) {
                            isValidProduct = true;
                            break;
                        }
                    }
                    if (!isValidProduct) {
                        continue;
                    }
                    String type = ces[j].getAttribute("table-type").trim();
                    AbstractNode childNode = (AbstractNode) ces[j].createExecutableExtension("class");
                    childNode.setParent(this);
                    childNode.setSession(_session);
                    childNode.setType(type);
                    addChildNode(childNode);
                } catch (Throwable ex) {
                    SQLExplorerPlugin.error("Could not create child node", ex);
                }
            }
        }
    } catch (Exception e) {
        SQLExplorerPlugin.error("Error loading children", e);
    }
}
Also used : SQLDatabaseMetaData(net.sourceforge.squirrel_sql.fw.sql.SQLDatabaseMetaData) ArrayList(java.util.ArrayList) IConfigurationElement(org.eclipse.core.runtime.IConfigurationElement) IExtensionPoint(org.eclipse.core.runtime.IExtensionPoint) SQLException(java.sql.SQLException) IExtensionPoint(org.eclipse.core.runtime.IExtensionPoint) IExtension(org.eclipse.core.runtime.IExtension) IExtensionRegistry(org.eclipse.core.runtime.IExtensionRegistry)

Aggregations

SQLDatabaseMetaData (net.sourceforge.squirrel_sql.fw.sql.SQLDatabaseMetaData)5 ArrayList (java.util.ArrayList)3 DatabaseMetaData (java.sql.DatabaseMetaData)2 SQLException (java.sql.SQLException)2 ITableInfo (net.sourceforge.squirrel_sql.fw.sql.ITableInfo)2 IExtensionPoint (org.eclipse.core.runtime.IExtensionPoint)2 DataSet (net.sourceforge.sqlexplorer.dataset.DataSet)1 SQLConnection (net.sourceforge.sqlexplorer.dbproduct.SQLConnection)1 INode (net.sourceforge.sqlexplorer.dbstructure.nodes.INode)1 TableNode (net.sourceforge.sqlexplorer.dbstructure.nodes.TableNode)1 SQLEditor (net.sourceforge.sqlexplorer.plugin.editors.SQLEditor)1 SQLEditorInput (net.sourceforge.sqlexplorer.plugin.editors.SQLEditorInput)1 PrimaryKeyInfo (net.sourceforge.squirrel_sql.fw.sql.PrimaryKeyInfo)1 TableColumnInfo (net.sourceforge.squirrel_sql.fw.sql.TableColumnInfo)1 IConfigurationElement (org.eclipse.core.runtime.IConfigurationElement)1 IExtension (org.eclipse.core.runtime.IExtension)1 IExtensionRegistry (org.eclipse.core.runtime.IExtensionRegistry)1 IEditorInput (org.eclipse.ui.IEditorInput)1 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)1 PartInitException (org.eclipse.ui.PartInitException)1