Studyon Minte9.com
Jdbc




Resultset column names




... public TreeMap select(String table) { TreeMap data = new TreeMap<Integer, Properties>(); try { Statement stmt = con.createStatement(); ResultSet rs = stmt.executeQuery("SELECT * FROM " + table); ResultSetMetaData rsMetaData = rs.getMetaData(); // --- Look Here --- // int count = rsMetaData.getColumnCount(); int i=0; while( rs.next() ) { Properties p = new Properties(); for (int k=1; k<=count; k++) { String colname = rsMetaData.getColumnLabel(k); // --- Look Here --- // p.put(colname, rs.getString(colname)); } data.put(i++, p); } stmt.close(); } catch (Exception e) {} return data; }


http://stackoverflow.com/questions/19094999/java-how-to-get-column-name-on-result-set