rs = stmt.executeQuery(new_cxyj);
ResultSetMetaData rsma = rs.getMetaData();
int size = rsma.getColumnCount();
JSONArray arr = new JSONArray();
while(rs.next()){
JSONObject obj = new JSONObject();
for (int i = 1; i <= size; i++) {
String s = rs.getString(rsma.getColumnName(i)) == null?"":rs.getString(rsma.getColumnName(i));
if(s==null||"".equals(s)){
s="无";
}
obj.put(rsma.getColumnName(i), s);
}
arr.add(obj);
}
转载于:https://www.cnblogs.com/chai-blogs/p/5291027.html