
1条回答 默认 最新
tianxuanv587 2020-05-30 16:48关注根据你的意思理解,就是想返回一个表的有列名,并以数组返回,根据你现有代码,加入了数组。
ResultSet rs = ps.executeQuery(); if (rs != null) { int count = rs.getMetaData().getColumnCount(); String[] colNames = new String[count]; //这个数组用来存放一行的所有字段 while(rs.next()){ for(int i = 1; i<=count; i++) { String field = rs.getMetaData().getColumnName(i); colNames[i] = field; } break; } } connection.close(); ps.close(); return colNames;解决 无用评论 打赏 举报