Examples of ITableInfo


Examples of net.sourceforge.squirrel_sql.fw.sql.ITableInfo

  protected IDataSet createDataSet() throws DataSetException
  {
    final ISQLConnection conn = getSession().getSQLConnection();
        final SQLDatabaseMetaData dmd = conn.getSQLMetaData();
       
        ITableInfo ti = getTableInfo();
        if (! "TABLE".equalsIgnoreCase(ti.getType())) {
          // Frontbase describes it's tables as "BASE TABLE".
          if (!DialectFactory.isFrontBase(dmd)) {
            return null
          }
        }
View Full Code Here

Examples of net.sourceforge.squirrel_sql.fw.sql.ITableInfo

  {
    try
    {
      final ISQLConnection conn = getSession().getSQLConnection();
      final SQLDatabaseMetaData md = conn.getSQLMetaData();
      final ITableInfo ti = getTableInfo();
      final BestRowIdentifier[] bris = md.getBestRowIdentifier(ti);
      return new JavabeanArrayDataSet(AdapterFactory.getInstance().createBestRowIdentifierAdapter(bris));
    }
    catch (SQLException ex)
    {
View Full Code Here

Examples of net.sourceforge.squirrel_sql.fw.sql.ITableInfo

   */
  protected IDataSet createDataSet() throws DataSetException
  {
    final SQLDatabaseMetaData md =
            getSession().getSQLConnection().getSQLMetaData();
        ITableInfo ti = getTableInfo();
        return md.getTablePrivilegesDataSet(ti, columnIndices, true);
  }
View Full Code Here

Examples of net.sourceforge.squirrel_sql.fw.sql.ITableInfo

   */
  protected IDataSet createDataSet() throws DataSetException
  {
    final SQLDatabaseMetaData md =
            getSession().getSQLConnection().getSQLMetaData();
        final ITableInfo ti = getTableInfo();
        return md.getColumnPrivilegesDataSet(ti,columnIndices, true);
  }
View Full Code Here

Examples of net.sourceforge.squirrel_sql.fw.sql.ITableInfo

         }


         if (doi instanceof ITableInfo)
         {
            ITableInfo ti = (ITableInfo) doi;
            DatabaseObjectType dot = ti.getDatabaseObjectType();

            String[] types = null;
            if (DatabaseObjectType.TABLE == dot)
            {
               types = new String[]{"TABLE"};
            }
            else if (DatabaseObjectType.VIEW == dot)
            {
               types = new String[]{"VIEW"};
            }

            _schemaInfoCache.clearTables(ti.getCatalogName(), ti.getSchemaName(), ti.getSimpleName(), types);
            loadTables(ti.getCatalogName(), ti.getSchemaName(), ti.getSimpleName(), types, 1);
         }
         else if(doi instanceof IProcedureInfo)
         {
            IProcedureInfo pi = (IProcedureInfo) doi;
            _schemaInfoCache.clearStoredProcedures(pi.getCatalogName(), pi.getSchemaName(), pi.getSimpleName());
View Full Code Here

Examples of net.sourceforge.squirrel_sql.fw.sql.ITableInfo

               catch (Exception ex)
               {
                  s_log.error("Error on Statement.setMaxRows()", ex);
               }
            }
            final ITableInfo ti = getTableInfo();

            /**
             * When the SessionProperties are set to read-only (either table or text)
             * but the user has selected "Make Editable" on the Popup menu, we want
             * to limit the edit capability to only that table, and only for as long
             * as the user is looking at that one table.  When the user switches away
             * to another table, that new table should not be editable.
             */
            final String currentTableName = ti.getQualifiedName();
            if (!currentTableName.equals(previousTableName))
            {
               previousTableName = currentTableName;  // needed to prevent an infinite loop
               _dataSetUpdateableTableModel.setEditModeForced(false);

               /**
                * Tell the GUI to rebuild itself.
                * Unfortunately, this has the side effect of calling this same function
                * another time.  The second call does not seem to be a problem,
                * but we need to have reset the previousTableName before makeing
                * this call or we will be in an infinite loop.
                */
               //props.forceTableContentsOutputClassNameChange();
            }

            /**
             * If the table has a pseudo-column that is the best unique
             * identifier for the rows (like Oracle's rowid), then we
             * want to include that field in the query so that it will
             * be available if the user wants to edit the data later.
             */
            String pseudoColumn = "";

            try
            {
               BestRowIdentifier[] rowIDs = md.getBestRowIdentifier(ti);
               for (int i = 0; i < rowIDs.length; ++i)
               {
                  short pseudo = rowIDs[i].getPseudoColumn();
                  if (pseudo == DatabaseMetaData.bestRowPseudo)
                  {
                     pseudoColumn = " ," + rowIDs[i].getColumnName();
                     break;
                  }
               }
            }

            // Some DBMS's (EG Think SQL) throw an exception on a call to
            // getBestRowIdentifier.
            catch (Throwable th)
            {
              if (s_log.isDebugEnabled()) {
                 s_log.debug("getBestRowIdentifier not supported for table "+ currentTableName, th);
              }
            }

            // TODO: - Col - Add method to Databasemetadata that returns array
            // of objects for getBestRowIdentifier. For PostgreSQL put this kludge in
            // the new function. THis way all the kludges are kept in one place.
            //
            // KLUDGE!!!!!!
            //
            // For some DBs (e.g. PostgreSQL) there is actually a pseudo-column
            // providing the rowId, but the getBestRowIdentifier function is not
            // implemented.  This kludge hardcodes the knowledge that specific
            // DBs use a specific pseudo-column.  Additionally, as of pg 8.1,
            // you must create the table using "WITH OID" appended to the create
            // statement.  Otherwise, OID column is not available by default.
            //
            if (pseudoColumn.length() == 0)
            {
                if (DialectFactory.isPostgreSQL(md)) {
                    pseudoColumn = ", oid";
                }
                if (DialectFactory.isOracle(md)) {
                    pseudoColumn = ", ROWID";
                }
            }

            ResultSet rs = null;
            try
            {
               // Note. Some DBMSs such as Oracle do not allow:
               // "select *, rowid from table"
               // You cannot have any column name in the columns clause
               // if you have * in there. Aliasing the table name seems to
               // be the best way to get around the problem.
               final StringBuffer buf = new StringBuffer();
               buf.append("select tbl.*")
                  .append(pseudoColumn)
                  .append(" from ")
                  .append(ti.getQualifiedName())
                  .append(" tbl");

               String clause = _sqlFilterClauses.get(WhereClausePanel.getClauseIdentifier(), ti.getQualifiedName());
               if ((clause != null) && (clause.length() > 0))
               {
                 buf.append(" where ").append(clause);
               }
               clause = _sqlFilterClauses.get(OrderByClausePanel.getClauseIdentifier(), ti.getQualifiedName());
               if ((clause != null) && (clause.length() > 0))
               {
                 buf.append(" order by ").append(clause);
               }

               if (s_log.isDebugEnabled()) {
                   s_log.debug("createDataSet running SQL: "+buf.toString());
               }
                          
               showWaitDialog(stmt);              

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

            }
            catch (SQLException ex)
            {
                if (s_log.isDebugEnabled()) {
                        s_log.debug(
                            "createDataSet: exception from pseudocolumn query - "
                                    + ex, ex);
                    }
                // We assume here that if the pseudoColumn was used in the query,
                // then it was likely to have caused the SQLException.  If not,
                // (length == 0), then retrying the query won't help - just throw
                // the exception.
               if (pseudoColumn.length() == 0)
               {
                  throw ex;
               }
               // pseudocolumn query failed, so reset it.  Otherwise, we'll
               // mistake the last column for a pseudocolumn and make it
               // uneditable
               pseudoColumn = "";

               // Some tables have pseudo column primary keys and others
               // do not.  JDBC on some DBMSs does not handle pseudo
               // columns 'correctly'.  Also, getTables returns 'views' as
               // well as tables, so the thing we are looking at might not
               // be a table. (JDBC does not give a simple way to
               // determine what we are looking at since the type of
               // object is described in a DBMS-specific encoding.)  For
               // these reasons, rather than testing for all these
               // conditions, we just try using the pseudo column info to
               // get the table data, and if that fails, we try to get the
               // table data without using the pseudo column.
               // TODO: Should we change the mode from editable to
               // non-editable?
               final StringBuffer buf = new StringBuffer();
               buf.append("select *")
                  .append(" from ")
                  .append(ti.getQualifiedName())
                  .append(" tbl");

               String clause = _sqlFilterClauses.get(WhereClausePanel.getClauseIdentifier(), ti.getQualifiedName());
               if ((clause != null) && (clause.length() > 0))
               {
                 buf.append(" where ").append(clause);
               }
               clause = _sqlFilterClauses.get(OrderByClausePanel.getClauseIdentifier(), ti.getQualifiedName());
               if ((clause != null) && (clause.length() > 0))
               {
                 buf.append(" order by ").append(clause);
               }

View Full Code Here

Examples of net.sourceforge.squirrel_sql.fw.sql.ITableInfo

    super.setUp();
    classUnderTest = new RowCountTab();
    super.clazz = RowCountTab.class;

    Statement localMockStatement = localMockHelper.createMock("localMockStatement", Statement.class);
    ITableInfo localMockTableInfo = localMockHelper.createMock("localMockTableInfo", ITableInfo.class);
    ResultSet localMockResultSet = localMockHelper.createMock("localMockResultSet", ResultSet.class);
    ResultSetMetaData localMockResultSetMetaData =
      localMockHelper.createMock("localMockResultSetMetaData", ResultSetMetaData.class);

    expect(localMockStatement.executeQuery(isA(String.class))).andStubReturn(localMockResultSet);
    expect(localMockResultSet.getMetaData()).andStubReturn(localMockResultSetMetaData);
    expect(localMockResultSetMetaData.getColumnCount()).andStubReturn(1);
    expect(localMockResultSetMetaData.isNullable(1)).andStubReturn(ResultSetMetaData.columnNullable);
    expect(localMockResultSetMetaData.getPrecision(1)).andStubReturn(1);
    expect(localMockResultSetMetaData.isSigned(1)).andStubReturn(false);
    expect(localMockResultSetMetaData.isCurrency(1)).andStubReturn(false);
    expect(localMockResultSetMetaData.isAutoIncrement(1)).andStubReturn(false);
    expect(localMockResultSetMetaData.getColumnName(1)).andStubReturn("testColumnName");
    expect(localMockResultSetMetaData.getColumnTypeName(1)).andStubReturn("INTEGER");
    expect(localMockResultSetMetaData.getColumnType(1)).andStubReturn(INTEGER);
    expect(localMockResultSetMetaData.getColumnDisplaySize(1)).andStubReturn(10);
    expect(localMockResultSetMetaData.getColumnLabel(1)).andStubReturn("testColumnLabel");
    expect(localMockResultSetMetaData.getScale(1)).andStubReturn(0);
    expect(localMockResultSet.next()).andReturn(true);
    expect(localMockResultSet.next()).andReturn(false);
    expect(localMockResultSet.getObject(1)).andStubReturn("10");
    expect(localMockResultSet.wasNull()).andReturn(false);
   
   
    localMockStatement.close();
    localMockResultSet.close();
   

    expect(localMockTableInfo.getQualifiedName()).andStubReturn(TEST_QUALIFIED_NAME);

    expect(mockSQLConnection.createStatement()).andStubReturn(localMockStatement);
    localMockHelper.replayAll();

    ((RowCountTab) classUnderTest).setTableInfo(localMockTableInfo);
View Full Code Here

Examples of net.sourceforge.squirrel_sql.fw.sql.ITableInfo

      localMockHelper.createMock("mockSquirrelPreferences", SquirrelPreferences.class);
    ISession localMockSession = localMockHelper.createMock("localMockSession", ISession.class);
    IApplication localMockApplication =
      localMockHelper.createMock("localMockApplication", IApplication.class);
    Statement localMockStatement = localMockHelper.createMock("localMockStatement", Statement.class);
    ITableInfo localMockTableInfo = localMockHelper.createMock("localMockTableInfo", ITableInfo.class);
    ResultSet localMockResultSet = localMockHelper.createMock("localMockResultSet", ResultSet.class);
    ResultSetMetaData localMockResultSetMetaData =
      localMockHelper.createMock("localMockResultSetMetaData", ResultSetMetaData.class);

    expect(localMockObjectTreePanel.getSession()).andStubReturn(localMockSession);
    expect(localMockSession.getApplication()).andStubReturn(localMockApplication);
    expect(localMockApplication.getSquirrelPreferences()).andStubReturn(localMockSquirrelPreferences);
    expect(localMockSquirrelPreferences.getShowPleaseWaitDialog()).andStubReturn(false);
    expect(localMockTableInfo.getQualifiedName()).andStubReturn("Test Qualified TableName");

    localMockStatement.close();
    expect(localMockResultSet.getMetaData()).andStubReturn(localMockResultSetMetaData);
   
    // localMockResultSetMetaData
View Full Code Here

Examples of net.sourceforge.squirrel_sql.fw.sql.ITableInfo

  {
    super.setUp();
    classUnderTest = new IndexesTab();
    super.clazz = IndexesTab.class;
   
    ITableInfo localMockTableInfo = mockHelper.createMock("localMockTableInfo", ITableInfo.class);
    EasyMock.expect(localMockTableInfo.getType()).andStubReturn("testTableType");
   
    ((IndexesTab)classUnderTest).setTableInfo(localMockTableInfo);
   
  }
View Full Code Here

Examples of net.sourceforge.squirrel_sql.fw.sql.ITableInfo

         String actualTableName = iTableInfo.getSimpleName();
         assertEquals(expectedTableName, actualTableName);
      }

      /* Pick a tableInfo to remove and replace */
      ITableInfo ti = tableInfos[5];
     
      /* remove table with name table10 */
      schemaInfoCacheUnderTest.clearTables(testCatalog, testSchema, ti.getSimpleName(),
            new String[] { testTableType });

      /* Add it back */
      schemaInfoCacheUnderTest.writeToTableCache(ti);
     
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.