//rs方法publicstaticvoidResultsetToArray(ResultSetrs)throwsSQLException{ResultSetMetaDatameta=rs.getMetaData();intcolumnCount=meta.getColumnCount();String[]strutName=newS...
//rs 方法
public static void ResultsetToArray(ResultSet rs) throws SQLException{
ResultSetMetaData meta = rs.getMetaData();
int columnCount = meta.getColumnCount();
String[] strutName = new String[columnCount];
byte[] strutType = new byte[columnCount];
rs.last();
int itemCount = rs.getRow();
rs.first();
Object[][] data = new Object[itemCount][columnCount];
for(int i=1;i<=2;i++){
strutType[i-1] = (byte)meta.getColumnType(i);
strutName[i-1] = meta.getColumnName(i);
// System.out.println(strutName[i-1]);
// System.out.println(rs.geto);
}
for(int i=1;i<=itemCount;i++){
for(int j=1;j<=columnCount;j++){
data[i-1][j-1] = rs.getObject(j);
System.out.println(data[i-1][j-1]);
// System.out.println("iiii="+i);
// System.out.println("j="+j);
//
}
}
}
这是结果!
001
jiangtao
001
jiangtao
001
jiangtao
001
jiangtao
两个FOR循环里面 的rs.getobject(j)取得值怎么 向下
展开