Package net.sourceforge.squirrel_sql.fw.datasetviewer

Examples of net.sourceforge.squirrel_sql.fw.datasetviewer.ResultSetDataSet


          // Frontbase describes it's tables as "BASE TABLE".
          if (!DialectFactory.isFrontBase(dmd)) {
            return null
          }
        }
        ResultSetDataSet rsds =
            dmd.getIndexInfo(getTableInfo(), indexIndices, true);
        rsds.next(null);
        String indexName = (String)rsds.get(1);
        if (indexName == null) {
            rsds.removeRow(0);
        }
        rsds.resetCursor();
        return rsds;
  }
View Full Code Here


      {
        final ResultSet rs = stmt.executeQuery("select count(*) from "
                        + getTableInfo().getQualifiedName());
        try
        {
          final ResultSetDataSet rsds = new ResultSetDataSet();
          rsds.setResultSet(rs, getDialectType());
          return rsds;
        }
        finally
        {
          rs.close();
View Full Code Here

               }

               rs = stmt.executeQuery(buf.toString());
            }

            final ResultSetDataSet rsds = new ResultSetDataSet();

            // to allow the fw to save and reload user options related to
            // specific columns, we construct a unique name for the table
            // so the column can be associcated with only that table.
            // Some drivers do not provide the catalog or schema info, so
            // those parts of the name will end up as null.  That's ok since
            // this string is never viewed by the user and is just used to
            // distinguish this table from other tables in the DB.
            // We also include the URL used to connect to the DB so that
            // the same table/DB on different machines is treated differently.
            rsds.setContentsTabResultSet(rs,
                                         _dataSetUpdateableTableModel.getFullTableName(),
                                         DialectFactory.getDialectType(md));
            if (rs != null) {
                try { rs.close(); } catch (SQLException e) {}
            }
            // KLUDGE:
            // We want some info about the columns to be available for validating the
            // user input during cell editing operations.  Ideally we would get that
            // info inside the ResultSetDataSet class during the creation of the
            // columnDefinition objects by using various functions in ResultSetMetaData
            // such as isNullable(idx).  Unfortunately, in at least some DBMSs (e.g.
            // Postgres, HSDB) the results of those calls are not the same (and are less accurate
            // than) the SQLMetaData.getColumns() call used in ColumnsTab to get the column info.
            // Even more unfortunate is the fact that the set of attributes reported on by the two
            // calls is not the same, with the ResultSetMetadata listing things not provided by
            // getColumns.  Most of the data provided by the ResultSetMetaData calls is correct.
            // However, the nullable/not-nullable property is not set correctly in at least two
            // DBMSs, while it is correct for those DBMSs in the getColumns() info.  Therefore,
            // we collect the collumn nullability information from getColumns() and pass that
            // info to the ResultSet to override what it got from the ResultSetMetaData.
            TableColumnInfo[] columnInfos = md.getColumnInfo(getTableInfo());
            final ColumnDisplayDefinition[] colDefs =
                rsds.getDataSetDefinition().getColumnDefinitions();

            // get the nullability information and pass it into the ResultSet
            // Unfortunately, not all DBMSs provide the column number in object 17 as stated in the
            // SQL documentation, so we have to guess that the result set is in column order
            for (int i = 0; i < columnInfos.length; i++) {
                boolean isNullable = true;
                TableColumnInfo info = columnInfos[i];
                if (info.isNullAllowed() == DatabaseMetaData.columnNoNulls) {
                    isNullable = false;
                }
                if (i < colDefs.length) {
                    colDefs[i].setIsNullable(isNullable);
                }
            }

            //?? remember which column is the rowID (if any) so we can
            //?? prevent editing on it
            if (pseudoColumn.length() > 0)
            {
               _dataSetUpdateableTableModel.setRowIDCol(rsds.getColumnCount() - 1);
            }

            return rsds;
         }
         finally
View Full Code Here

   */
  protected abstract PreparedStatement createStatement() throws SQLException;

  protected IDataSet createDataSetFromResultSet(ResultSet rs) throws DataSetException
  {
    final ResultSetDataSet rsds = new ResultSetDataSet();
    rsds.setResultSet(rs, getDialectType());
    if (!_firstRowOnly)
    {
      return rsds;
    }

    final int columnCount = rsds.getColumnCount();
    final ColumnDisplayDefinition[] colDefs = rsds.getDataSetDefinition().getColumnDefinitions();
    final Map<String, Object> data = new HashMap<String, Object>();
    if (rsds.next(null))
    {
      for (int i = 0; i < columnCount; ++i)
      {
        data.put(colDefs[i].getColumnName(), rsds.get(i));
      }
    }
    return new MapDataSet(data);

  }
View Full Code Here

    {
      DatabaseMetaData md = privateGetJDBCMetaData();
      final String columns = DialectFactory.isMySQL(this) ? "%" : null;

      rs = md.getColumnPrivileges(ti.getCatalogName(), ti.getSchemaName(), ti.getSimpleName(), columns);
      ResultSetDataSet rsds = new ResultSetDataSet();
      rsds.setResultSet(rs, columnIndices, computeWidths, DialectFactory.getDialectType(this));
      return rsds;
    }
    catch (SQLException e)
    {
      throw new DataSetException(e);
View Full Code Here

    try
    {
      rs =
        privateGetJDBCMetaData().getExportedKeys(ti.getCatalogName(), ti.getSchemaName(),
          ti.getSimpleName());
      ResultSetDataSet rsds = new ResultSetDataSet();
      rsds.setResultSet(rs, null, true, DialectFactory.getDialectType(this));
      return rsds;
    }
    catch (SQLException e)
    {
      throw new DataSetException(e);
View Full Code Here

    try
    {
      rs =
        privateGetJDBCMetaData().getImportedKeys(ti.getCatalogName(), ti.getSchemaName(),
          ti.getSimpleName());
      ResultSetDataSet rsds = new ResultSetDataSet();
      rsds.setResultSet(rs, null, true, DialectFactory.getDialectType(this));
      return rsds;
    }
    catch (SQLException e)
    {
      throw new DataSetException(e);
View Full Code Here

    try
    {
      rs =
        privateGetJDBCMetaData().getIndexInfo(ti.getCatalogName(), ti.getSchemaName(),
          ti.getSimpleName(), false, true);
      ResultSetDataSet rsds = new ResultSetDataSet();
      rsds.setResultSet(rs, columnIndices, computeWidths, DialectFactory.getDialectType(this));
      return rsds;
    }
    catch (SQLException e)
    {
      throw new DataSetException(e);
View Full Code Here

    try
    {
      rs =
        privateGetJDBCMetaData().getPrimaryKeys(ti.getCatalogName(), ti.getSchemaName(),
          ti.getSimpleName());
      ResultSetDataSet rsds = new ResultSetDataSet();
      rsds.setResultSet(rs, columnIndices, computeWidths, DialectFactory.getDialectType(this));
      return rsds;
    }
    catch (SQLException e)
    {
      throw new DataSetException(e);
View Full Code Here

    ResultSet rs = null;
    try
    {
      DatabaseMetaData md = privateGetJDBCMetaData();
      rs = md.getProcedureColumns(ti.getCatalogName(), ti.getSchemaName(), ti.getSimpleName(), "%");
      ResultSetDataSet rsds = new ResultSetDataSet();
      rsds.setResultSet(rs, DialectFactory.getDialectType(this));
      return rsds;
    }
    catch (SQLException e)
    {
      throw new DataSetException(e);
View Full Code Here

TOP

Related Classes of net.sourceforge.squirrel_sql.fw.datasetviewer.ResultSetDataSet

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.