Package net.sourceforge.squirrel_sql.fw.sql

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


   * @see net.sourceforge.squirrel_sql.plugins.refactoring.commands.AbstractRefactoringCommand#onExecute()
   */
  @Override
  protected void onExecute() throws SQLException
  {
    ITableInfo selectedTable = (ITableInfo) _info[0];
    TableColumnInfo[] tableColumnInfos = _session.getMetaData().getColumnInfo(selectedTable);

    if (tableColumnInfos.length == 1)
    {
      columnToModify = tableColumnInfos[0];
      showCustomDialog();
    } else
    {
      listDialog = new ColumnListDialog(tableColumnInfos, ColumnListDialog.MODIFY_COLUMN_MODE);
      listDialog.addColumnSelectionListener(new ColumnListSelectionActionListener());
      listDialog.setLocationRelativeTo(_session.getApplication().getMainFrame());
      listDialog.setSingleSelection();
      listDialog.setTableName(selectedTable.getSimpleName());
      listDialog.setVisible(true);
    }
  }
View Full Code Here


    return result;
  }

  private void showCustomDialog() throws SQLException
  {
    ITableInfo selectedTable = (ITableInfo) _info[0];
    TableColumnInfo[] tableColumnInfos = _session.getMetaData().getColumnInfo(selectedTable);
    TreeSet<String> localColumns = new TreeSet<String>();
    for (TableColumnInfo columns : tableColumnInfos)
    {
      localColumns.add(columns.getColumnName());
    }

    customDialog =
      new MergeColumnDialog(selectedTable.getSimpleName(), localColumns.toArray(new String[] {}));
    customDialog.addExecuteListener(new ExecuteListener());
    customDialog.addEditSQLListener(new EditSQLListener(customDialog));
    customDialog.addShowSQLListener(new ShowSQLListener(i18n.SHOWSQL_DIALOG_TITLE, customDialog));
    customDialog.setLocationRelativeTo(_session.getApplication().getMainFrame());
    customDialog.setVisible(true);
View Full Code Here

      showCustomDialog();
      return;
    }
    else
    {
      ITableInfo ti = (ITableInfo) _info[0];
      _tableName = ti.getSimpleName();
      _dropIndexInfo =
        _session.getSQLConnection().getSQLMetaData().getIndexInfo(ti).toArray(new IndexInfo[] {});
    }

    // Don't show indexes dialog if only one index exists to be modified
View Full Code Here


         StringBuffer script = new StringBuffer();
         for (int i = 0; i < dbObjs.length; i++)
         {
            ITableInfo ti = (ITableInfo) dbObjs[i];

            stat.setString(1, ti.getSimpleName());
            if (s_log.isDebugEnabled()) {
                s_log.debug("Running SQL: "+sql);
                s_log.debug("Bind var value is: "+ti.getSimpleName());
            }
            ResultSet res = stat.executeQuery();

            while(res.next())
            {
View Full Code Here

        String destCatalog = prov.getDestSelectedDatabaseObject().getCatalogName();
        for (int i = 0; i < sourceObjs.length; i++) {
            if (false == sourceObjs[i] instanceof ITableInfo) {
                continue;
            }
            ITableInfo sourceTI = (ITableInfo)sourceObjs[i];
            sendTableCopyStarted(sourceTI, i+1);
            try {
                int destTableCount = DBUtil.getTableCount(destSession,
                                                          destCatalog,
                                                          destSchema,
                                                          sourceTI.getSimpleName(),
                                                          DialectFactory.DEST_TYPE);
                if (destTableCount == -1) {
                    createTable(sourceTI);
                }
                if (destTableCount > 0) {
                    try {
                        String t = sourceTI.getSimpleName();
                        if (pref.appendRecordsToExisting(t)) {
                            /* Do nothing */
                        } else if (pref.deleteTableData(sourceTI.getSimpleName())) {
                            // Yes || Yes to all
                            DBUtil.deleteDataInExistingTable(destSession,
                                                             destCatalog,
                                                             destSchema,
                                                             sourceTI.getSimpleName());
                        } else {
                            continue; // skip this table, try the next.
                        }
                       
                    } catch (UserCancelledOperationException e) {
View Full Code Here

        }
        sendAnalysisStarted();
        try {
            IDatabaseObjectInfo[] dbObjs = prov.getSourceSelectedDatabaseObjects();       
            for (int tableIdx = 0; tableIdx < dbObjs.length; tableIdx++) {
                ITableInfo ti = (ITableInfo)dbObjs[tableIdx];
                sendAnalyzingTable(ti, tableIdx);
                DBUtil.validateColumnNames(ti, prov);
            }
        } catch (MappingException e) {
            sendErrorEvent(ErrorEvent.MAPPING_EXCEPTION_TYPE, e);
View Full Code Here

            for (int i = 0; i < dbObjs.length; i++) {
                if (false == dbObjs[i] instanceof ITableInfo) {
                    continue;
                }         
                try {
                    ITableInfo ti = (ITableInfo) dbObjs[i];
                    selectedTableInfos.add(ti);
                    // This doesn't appear to work for PROGRESS RDBMS
                    //result[i] = DBUtil.getTableCount(con, ti.getSimpleName());
                    result[i] =
                        DBUtil.getTableCount(sourceSession,
                                             ti.getCatalogName(),
                                             ti.getSchemaName(),
                                             ti.getSimpleName(),
                                             DialectFactory.SOURCE_TYPE);
                } catch (Exception e) {
                    log.error("",e);
                    result[i] = 0;
                }
View Full Code Here

        SQLDatabaseMetaData sourceMetaData = sourceConn.getSQLMetaData();
        SQLDatabaseMetaData destMetaData = destConn.getSQLMetaData();
        try {
            String destSchema =
                prov.getDestSelectedDatabaseObject().getSimpleName();           
            ITableInfo destTableInfo =
                DBUtil.getTableInfo(prov.getCopyDestSession(),
                                    destSchema,
                                    sourceTableInfo.getSimpleName());
           
            TableColumnInfo[] sourceInfos = sourceMetaData.getColumnInfo(sourceTableInfo);
            TableColumnInfo[] destInfos = destMetaData.getColumnInfo(destTableInfo);
           
            destInfos = sort(sourceInfos,
                             destInfos,
                             sourceTableInfo.getQualifiedName(),
                             destTableInfo.getQualifiedName());
           
            String sourceColList = DBUtil.getColumnList(sourceInfos);
            String destColList = DBUtil.getColumnList(destInfos);
           
            String selectSQL = DBUtil.getSelectQuery(prov,
View Full Code Here

            || DialectFactory.isAxion(prov.getCopySourceSession().getMetaData())) {
            return;
        }
        ISQLConnection destConn = prov.getCopyDestSession().getSQLConnection();
        for (int i = 0; i < dbObjs.length; i++) {
            ITableInfo ti = (ITableInfo) dbObjs[i];
            Set<String> fkStmts =
                DBUtil.getForeignKeySQL(prov, ti, selectedTableInfos);
            Iterator<String> it = fkStmts.iterator();
            while (it.hasNext()) {
                String fkSQL = it.next();
View Full Code Here


         StringBuffer script = new StringBuffer();
         for (int i = 0; i < dbObjs.length; i++)
         {
            ITableInfo ti = (ITableInfo) dbObjs[i];

            ///////////////////////////////////////////////////////////
            // IBM DB 2 specific code to read view definitions.
            String sql =
               "SELECT TEXT " +
               "FROM SYSIBM.SYSVIEWS " +
               "WHERE NAME = '" + ti.getSimpleName() + "'";

            ResultSet res = stat.executeQuery(sql);
            res.next();

            script.append(res.getString("TEXT"));
View Full Code Here

TOP

Related Classes of net.sourceforge.squirrel_sql.fw.sql.ITableInfo

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.