在java中怎样用resultset方法把查询的表的所有值都显示出来

用sql2000,我是想把表里的内容都显示出来,你那不就只显示一种吗?难道得一个个赋值显示

首先确定你是什么库啊,得有数据库驱动
例mysql
Class.forName("com.mysql.jdbc.Driver");
Connection con = (Connection) DriverManager.getConnection(url, name,
pwd);
con.setAutoCommit(false);
Connection conn = null;
ResultSet rs;
try {
conn = getConnect(url,name,password);
String sql="select * from table ";
PreparedStatement ps = conn.prepareStatement(sql);
rs = ps.executeQuery(sql);
while(rs.next()){
//rs.getString(1);根据类型取值
}
温馨提示:内容为网友见解,仅供参考
第1个回答  2011-12-29
传个list
相似回答