转自: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;
}

 

相关文章:

  • 2021-07-01
  • 2021-12-02
  • 2022-12-23
  • 2021-07-11
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-02-18
猜你喜欢
  • 2022-01-07
  • 2022-12-23
  • 2022-02-27
  • 2021-05-25
  • 2021-12-19
  • 2022-01-04
  • 2021-09-21
相关资源
相似解决方案