public List compareSchema()

in src/main/java/com/datacompare/service/CompareService.java [1214:1295]


	public List<CompareResult> compareSchema(AppProperties appProperties, Connection sourceConn, Connection targetConn,
			String schemaName, List<String> columnList) {

		List<CompareResult> tableList = new ArrayList<CompareResult>();
		List<String> tableNames = new ArrayList<String>();

		ResultSet rs = null;

		try {

			List<String> ignoreTables = (appProperties.getTableName() != null && !appProperties.getTableName().isEmpty()
					&& appProperties.isIgnoreTables()) ? Arrays.asList(appProperties.getTableName().split(","))
					: new ArrayList<String>();

			String[] types = {"TABLE"};
			rs = sourceConn.getMetaData().getTables(null, schemaName.toUpperCase(), null, types);

			while (rs.next()) {

				String tableName = rs.getString("TABLE_NAME");

				if (ignoreTable(ignoreTables, tableName)) continue;

				tableNames.add(tableName);
			}

		} catch (SQLException ex) {

			logger.error(ex.getMessage(), ex);

		} finally {

			new JdbcUtil().closeResultSet(rs);
		}

	//	ExecutorService executor = Executors.newFixedThreadPool(10);
	//	Map<String, CompareResult> hashMap = new ConcurrentHashMap<String, CompareResult>();
		if (!tableNames.isEmpty()) {

			for (String tableName : tableNames) {
				StringBuilder info = new StringBuilder();
				info.append("\n----------------------------------------------------\n");
				info.append("Started Comparing Table Name: ");
				info.append(tableName);
				info.append(" in Schema: ");
				info.append(schemaName);
				logger.info(info.toString());
			/*	CompareResult dto = null;
				CompareTableResults compareTableResults = new CompareTableResults(dto, appProperties, sourceConn, targetConn,
						schemaName, tableName, columnList, hashMap);
				executor.execute(compareTableResults);
			}
			executor.shutdown();
			while (!executor.isTerminated()) {
			}
			for (final String key : hashMap.keySet()) {
				CompareResult dto = hashMap.get(key);*/
				CompareResult dto = compare(appProperties, sourceConn, targetConn, schemaName, tableName, columnList);
				//if (dto.getReason() == null && !(dto.getResult() != null && "Completed".equals(dto.getResult())) ) {
					//dto.setTableName(tableName);
				if (dto.getReason() == null && !(dto.getResult() != null && "Completed".equals(dto.getResult()))) {
					dto.setTableName(tableName);
					dto.setReason("Table " + schemaName + "." + tableName + " unable to compare.");
					dto.setResult("Failed");
				}

				tableList.add(dto);

	/*			StringBuilder info = new StringBuilder();

				info.append("\n----------------------------------------------------\n");
				info.append("Finished Comparing Table Name: ");
				info.append(key);
				info.append(" in Schema: ");
				info.append(schemaName);*/

				logger.info(info.toString());
			}
		}

		return tableList;
	}