private void addChangedTablesToGlobalVector(Vector<String> tableNamesDB1,Vector<String> tableNamesDB2) throws SQLException {
  final PreparedStatement stmtGetColumNamesForTable1=con1.prepareStatement("select column_name from user_tab_columns where table_name=?");
  final PreparedStatement stmtGetColumNamesForTable2=con2.prepareStatement("select column_name from user_tab_columns where table_name=?");
  final PreparedStatement stmtGetColumDetailsDB1=con1.prepareStatement("select * from user_tab_columns where column_name=? and table_name=?");
  final PreparedStatement stmtGetColumDetailsDB2=con2.prepareStatement("select * from user_tab_columns where column_name=? and table_name=?");
  Iterator iter=tableNamesDB2.iterator();
  while (iter.hasNext()) {
    String tableName=(String)iter.next();
    if (tableNamesDB1.contains(tableName)) {
      final Vector<String> columnNamesDB1=new Vector<String>();
      final Vector<String> columnNamesDB2=new Vector<String>();
      stmtGetColumNamesForTable1.setString(1,tableName);
      stmtGetColumNamesForTable2.setString(1,tableName);
      ResultSet rs=stmtGetColumNamesForTable1.executeQuery();
      while (rs.next()) {
        columnNamesDB1.add(rs.getString("COLUMN_NAME"));
      }
      rs.close();
      rs=stmtGetColumNamesForTable2.executeQuery();
      while (rs.next()) {
        columnNamesDB2.add(rs.getString("COLUMN_NAME"));
      }
      rs.close();
      final Vector<String> addedColumns=getNewElements(columnNamesDB1,columnNamesDB2);
      if (addedColumns.size() != 0) {
        final Table table=new Table(tableName);
        for (int i=0; i < addedColumns.size(); i++) {
          stmtGetColumDetailsDB2.setString(1,addedColumns.get(i));
          stmtGetColumDetailsDB2.setString(2,tableName);
          rs=stmtGetColumDetailsDB2.executeQuery();
          while (rs.next()) {
            final Column column=new Column(rs);
            if (!column.isNullable() && column.getDefaultValue() == null) {
              column.setTmpDefaultValue(getTempDefaultValueForColumn(tableName,column));
            }
            table.addColumnToAdd(column);
          }
          rs.close();
        }
        m_changedTables.add(table);
      }
      final Vector<String> missingColumns=getMissingElements(columnNamesDB1,columnNamesDB2);
      if (missingColumns.size() != 0) {
        final Table table=new Table(tableName);
        for (int i=0; i < missingColumns.size(); i++) {
          table.addColumnToDrop(new Column(missingColumns.get(i)));
        }
        m_changedTables.add(table);
      }
      Table changedTable=null;
      for (int i=0; i < columnNamesDB1.size(); i++) {
        String colName=columnNamesDB1.get(i);
        if (columnNamesDB2.contains(colName)) {
          stmtGetColumDetailsDB1.setString(1,colName);
          stmtGetColumDetailsDB1.setString(2,tableName);
          stmtGetColumDetailsDB2.setString(1,colName);
          stmtGetColumDetailsDB2.setString(2,tableName);
          Column colDB1=null;
          Column colDB2=null;
          rs=stmtGetColumDetailsDB1.executeQuery();
          if (rs.next()) {
            colDB1=new Column(rs);
          }
          rs.close();
          rs=stmtGetColumDetailsDB2.executeQuery();
          if (rs.next()) {
            colDB2=new Column(rs);
          }
          rs.close();
          if (!colDB1.equals(colDB2)) {
            if (changedTable == null) {
              changedTable=new Table(tableName);
            }
            if (!colDB2.isNullable() && colDB2.getDefaultValue() == null) {
              colDB2.setTmpDefaultValue(getTempDefaultValueForColumn(tableName,colDB2));
            }
            colDB2.setNullHasChanged(colDB2.isNullable() != colDB1.isNullable());
            final String def1=colDB1.getDefaultValue();
            final String def2=colDB2.getDefaultValue();
            if (def1 == null && def2 == null) {
              colDB2.setDefaultHasChanged(false);
            }
 else             if (def1 != null && def2 != null) {
              colDB2.setDefaultHasChanged(!def1.equals(def2));
            }
 else {
              colDB2.setDefaultHasChanged(true);
            }
            changedTable.addColumnToModify(colDB2);
          }
        }
      }
      if (changedTable != null) {
        m_changedTables.add(changedTable);
      }
    }
  }
  stmtGetColumNamesForTable1.close();
  stmtGetColumNamesForTable2.close();
  stmtGetColumDetailsDB1.close();
  stmtGetColumDetailsDB2.close();
}

private void addChangedTablesToGlobalVector ( Vector < String > tableNamesDB1 , Vector < String > tableNamesDB2 ) throws SQLException { final PreparedStatement stmtGetColumNamesForTable1 = con1 . prepareStatement ( "select column_name from user_tab_columns where table_name=?" ) ; final PreparedStatement stmtGetColumNamesForTable2 = con2 . prepareStatement ( "select column_name from user_tab_columns where table_name=?" ) ; final PreparedStatement stmtGetColumDetailsDB1 = con1 . prepareStatement ( "select * from user_tab_columns where column_name=? and table_name=?" ) ; final PreparedStatement stmtGetColumDetailsDB2 = con2 . prepareStatement ( "select * from user_tab_columns where column_name=? and table_name=?" ) ; Iterator iter = tableNamesDB2 . iterator ( ) ; while ( iter . hasNext ( ) ) { String tableName = ( String ) iter . next ( ) ; if ( tableNamesDB1 . contains ( tableName ) ) { final Vector < String > columnNamesDB1 = new Vector < String > ( ) ; final Vector < String > columnNamesDB2 = new Vector < String > ( ) ; stmtGetColumNamesForTable1 . setString ( 1 , tableName ) ; stmtGetColumNamesForTable2 . setString ( 1 , tableName ) ; ResultSet rs = stmtGetColumNamesForTable1 . executeQuery ( ) ; while ( rs . next ( ) ) { columnNamesDB1 . add ( rs . getString ( "COLUMN_NAME" ) ) ; } rs . close ( ) ; rs = stmtGetColumNamesForTable2 . executeQuery ( ) ; while ( rs . next ( ) ) { columnNamesDB2 . add ( rs . getString ( "COLUMN_NAME" ) ) ; } rs . close ( ) ; final Vector < String > addedColumns = getNewElements ( columnNamesDB1 , columnNamesDB2 ) ; if ( addedColumns . size ( ) != 0 ) { final Table table = new Table ( tableName ) ; for ( int i = 0 ; i < addedColumns . size ( ) ; i ++ ) { stmtGetColumDetailsDB2 . setString ( 1 , addedColumns . get ( i ) ) ; stmtGetColumDetailsDB2 . setString ( 2 , tableName ) ; rs = stmtGetColumDetailsDB2 . executeQuery ( ) ; while ( rs . next ( ) ) { final Column column = new Column ( rs ) ; if ( ! column . isNullable ( ) && column . getDefaultValue ( ) == null ) { column . setTmpDefaultValue ( getTempDefaultValueForColumn ( tableName , column ) ) ; } table . addColumnToAdd ( column ) ; } rs . close ( ) ; } m_changedTables . add ( table ) ; } final Vector < String > missingColumns = getMissingElements ( columnNamesDB1 , columnNamesDB2 ) ; if ( missingColumns . size ( ) != 0 ) { final Table table = new Table ( tableName ) ; for ( int i = 0 ; i < missingColumns . size ( ) ; i ++ ) { table . addColumnToDrop ( new Column ( missingColumns . get ( i ) ) ) ; } m_changedTables . add ( table ) ; } Table changedTable = null ; for ( int i = 0 ; i < columnNamesDB1 . size ( ) ; i ++ ) { String colName = columnNamesDB1 . get ( i ) ; if ( columnNamesDB2 . contains ( colName ) ) { stmtGetColumDetailsDB1 . setString ( 1 , colName ) ; stmtGetColumDetailsDB1 . setString ( 2 , tableName ) ; stmtGetColumDetailsDB2 . setString ( 1 , colName ) ; stmtGetColumDetailsDB2 . setString ( 2 , tableName ) ; Column colDB1 = null ; Column colDB2 = null ; rs = stmtGetColumDetailsDB1 . executeQuery ( ) ; if ( rs . next ( ) ) { colDB1 = new Column ( rs ) ; } rs . close ( ) ; rs = stmtGetColumDetailsDB2 . executeQuery ( ) ; if ( rs . next ( ) ) { colDB2 = new Column ( rs ) ; } rs . close ( ) ; if ( ! colDB1 . equals ( colDB2 ) ) { if ( changedTable == null ) { changedTable = new Table ( tableName ) ; } if ( ! colDB2 . isNullable ( ) && colDB2 . getDefaultValue ( ) == null ) { colDB2 . setTmpDefaultValue ( getTempDefaultValueForColumn ( tableName , colDB2 ) ) ; } colDB2 . setNullHasChanged ( colDB2 . isNullable ( ) != colDB1 . isNullable ( ) ) ; final String def1 = colDB1 . getDefaultValue ( ) ; final String def2 = colDB2 . getDefaultValue ( ) ; if ( def1 == null && def2 == null ) { colDB2 . setDefaultHasChanged ( false ) ; } else if ( def1 != null && def2 != null ) { colDB2 . setDefaultHasChanged ( ! def1 . equals ( def2 ) ) ; } else { colDB2 . setDefaultHasChanged ( true ) ; } changedTable . addColumnToModify ( colDB2 ) ; } } } if ( changedTable != null ) { m_changedTables . add ( changedTable ) ; } } } stmtGetColumNamesForTable1 . close ( ) ; stmtGetColumNamesForTable2 . close ( ) ; stmtGetColumDetailsDB1 . close ( ) ; stmtGetColumDetailsDB2 . close ( ) ; }
searches for changed tables and adds them to the global m_changedtables vector .
