Here you can find the source of getMysqlIndices(String conString)
public static HashMap<String, HashSet<String>> getMysqlIndices(String conString) throws SQLException
//package com.java2s; //License from project: Open Source License import java.sql.*; import java.util.*; public class Main { public static HashMap<String, HashSet<String>> getMysqlIndices(String conString) throws SQLException { HashMap<String, HashSet<String>> result = new HashMap<String, HashSet<String>>(); Connection conn;//from w w w . ja va 2s .c om conn = DriverManager.getConnection(conString); DatabaseMetaData meta = conn.getMetaData(); ResultSet tables = meta.getTables(null, null, null, null); while (tables.next()) { ResultSet rs; String tableName = tables.getString(3); rs = meta.getPrimaryKeys(null, null, tableName); HashSet<String> hash = new HashSet<String>(); result.put(tableName.toLowerCase(), hash); while (rs.next()) { hash.add(rs.getString("COLUMN_NAME")); // String columnName = rs.getString("COLUMN_NAME"); // System.out.println(tables.getString(3)); // System.out.println("getPrimaryKeys(): columnName=" + // columnName); } rs.close(); } tables.close(); conn.close(); return result; } }