怎样从数据库读出数据并用数组存储.
例如: 表: id name grade
1 张三 80
2 李四 90
3 王五 70
数组:
a[1]=1 b[1]=张三 c[1]=80
a[2]=2 b[2]=李四 c[2]=90
a[3]=3 b[3]=王五 c[3]=70
例如: 表: id name grade
1 张三 80
2 李四 90
3 王五 70
数组:
a[1]=1 b[1]=张三 c[1]=80
a[2]=2 b[2]=李四 c[2]=90
a[3]=3 b[3]=王五 c[3]=70
StringBuffer sSql = new StringBuffer(1024);
sSql.append("select name,grade from table");
rs = stmt.executeQuery(sSql.toString());
int i =1;
while(rs != null){
a[i] = i;
b[i] = rs.getString("name");
c[i] = rs.getString("grade");
i++;
}