别样 2006-6-5 14:33
如何将从数据库中取出的ResultSet对象转化为vector类型??
如何将从数据库中取出的ResultSet对象转化为vector类型??
悠着点 2006-6-5 14:34
[url]http://developer.java.sun.com/developer/technicalArticles/javaserverpages/cachedrowset/[/url]
tbp 2006-6-5 14:35
那就先把一条记录放到Hashtable中去,然后把hashtable放到vector中就是了。
先飞鸟 2006-6-5 14:36
接着
public static Vector doQuery(Connection cn, String sql)
throws SQLException
{
Connection conn = cn;
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery(sql);
ResultSetMetaData rsmd = rs.getMetaData();
int num = rsmd.getColumnCount();
Vector v = new Vector();
String str[];
for(; rs.next(); v.add(str))
{
str = new String[num];
for(int i = 0; i < num; i++)
{
str[i] = Util.str_null(rs.getString(i + 1));
}
}
rs.close();
stmt.close();
return v;
}