sql="............";
rs = stmt.executeQuery(sql);
rs = stmt.executeQuery(sql);
解决方案 »
- 请教带滚动条的Tabel怎样设置百分比的高度
- 修改一段js代码
- jsp文件改写成htm文件就乱码求解
- lin一样的配置在windows下运行正常,但项目布署到linux后上传图片出现问题,有遇到过类似问题的吗,等待中....
- jsp显示问题
- ERROR org.hibernate.impl.SessionFactoryImpl - Error in named query: searchFilm
- 连接数据库的错误
- 请教个基础的问题
- 如何得到某个指定Frame(不同进程的)某个Component(如TextBox等等)呢?
- 快帮帮我吧?还没解决.谢谢!
- xml文档生成问题
- JSP连接MSSQL出现的错误:请帮忙!!
String type = null;
String price = null;
conn = //getConnection
PreparedStatement psm = null;
ResultSet rs = null;
try {
psm = conn.prepareStatement(sql);
rs = psm.executeQuery();
while (rs.next()) {
type = rs.getString(1);
price = rs.getString(2);
}
} catch (SQLException sqlx) {
System.out.println("Got SQLException ! " + sqlx.toString());
} finally {
try {
if (rs != null)
rs.close();
if (psm != null)
psm.close();
if (conn != null)
conn.close();
} catch (Exception ex) {
System.out.println("Can't close Connection : " + ex.toString());
}
}
String sql = "select type,price from titles order by type compute sum(price) by ype compute sum(price)";
Connection conn = //getConnection
Hashtable ht=new Hashtable();
while (rs.next()) {
int i=0;
i++;
type = rs.getString(1);
price = rs.getString(2);
ht.put("a"+i,type);
ht.put("b"+i,price);
}
然后返回ht,
JSP中就会接到多个结果集的
jsp中同样用一个Hashtable来接收就可以了呀
2。用getMoreResults获得多个结果集
while (rs.next()) {
int i=0;
i++;
type = rs.getString(1);
price = rs.getString(2);
ht.put("a"+i,type);
ht.put("b"+i,price);
}int i=0;放在循环里面???