Java SQL ResultSet Read getDataDupls(ResultSet rs)

Here you can find the source of getDataDupls(ResultSet rs)

Description

get Data Dupls

License

Open Source License

Declaration

public static Map<String, List<Integer>> getDataDupls(ResultSet rs) throws SQLException 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class Main {
    public static Map<String, List<Integer>> getDataDupls(ResultSet rs) throws SQLException {
        Map<String, List<Integer>> mm = new HashMap<String, List<Integer>>();
        List<Integer> li;
        int cc = rs.getMetaData().getColumnCount();
        int j = 1;
        String prev = null;//w  w  w  .jav  a 2 s . c o  m
        String next;
        while (j <= cc) {
            if (j > 1)
                prev = rs.getString(j - 1);
            next = rs.getString(j);
            if (null != prev && prev.equals(next)) {
                if (mm.containsKey(prev)) {
                    li = mm.get(prev);
                    li.add(j);
                } else {
                    li = new ArrayList<Integer>();
                    li.add(j);
                    mm.put(prev, li);
                }
            } else {
                li = new ArrayList<Integer>();
                li.add(j);
                mm.put(next, li);
            }
            j++;
        }
        return mm;
    }
}

Related

  1. getCharacterStream(ResultSet resultSet, String columnName)
  2. getChunkDelimiters(ResultSet rs, int tsColumnIndex, int chunkSize)
  3. getClassName(ResultSetMetaData meta, int index)
  4. getCountFromResultSet(ResultSet rs)
  5. getData(final ResultSet rs)
  6. getDateList(ResultSet resultSet, String columnName)
  7. getDbDateValue(ResultSet rs, String columnName)
  8. getDebugData(ResultSet rs)
  9. getDuplicacy(ResultSet rs)