时间:2021-07-01 10:21:17 帮助过:59人阅读
public static String queryAll() {
Connection conn = null;
Statement sta = null;
ResultSet rs = null;
try {
PhoenixDB pDB = new PhoenixDB();
conn = pDB.getConn();
sta = conn.createStatement();
rs = sta.executeQuery("select * from tb");
ResultSetMetaData md = rs.getMetaData(); //获得结果集结构信息,元数据
int columnCount = md.getColumnCount(); //获得列数
while (rs.next()) {
List<Object> l = new ArrayList<Object>();
for (int i = 1; i <= columnCount; i++) {
l.add(rs.getObject(i));
}
list.add(l);
}
} catch (SQLException e) {
e.printStackTrace();
}
return "success";
}
将JDBC ResultSet结果集转成List
标签:lang query rom 结构 statement catch 避免 ace tco