转自:https://blog.csdn.net/song_litao/article/details/84751351
public List<String> getColumnName(){ Connection conn = null; PreparedStatement ps = null; ResultSet rs = null; List<String> cols = new ArrayList<String>(); try { conn = DBHelper.getConn(); ps = conn.prepareStatement("select * from tableName"); rs = ps.executeQuery(); ResultSetMetaData rsmd = rs.getMetaData(); for (int i = 1; i < rsmd.getColumnCount() + 1; i++) { String columnName = rsmd.getColumnName(i).toLowerCase(); cols.add(columnName); } } catch (Exception e) { throw new WAFException(e); } finally { DBHelper.close(conn, ps, rs); } return cols; }