javabean的写法:
----------------------------------------------------
import com.sun.rowset.CachedRowSetImpl;
public CachedRowSetImpl get_rsfarm(String s_user)
{
try
{
Connection con = DriverManager.getConnection("proxool.Access");
Statement stmt = con.createStatement();
String strSQL = "select * from res_farm where username='" + s_user + "'";
ResultSet rs = stmt.executeQuery(strSQL);
CachedRowSetImpl crs = new CachedRowSetImpl();
crs.populate(rs);//这里拿走CachedRowSetImpl
rs.close();
stmt.close();
con.close();
return crs;
}
catch(Exception e)
{
CachedRowSetImpl crs=null;
return crs;
}
-------------------------------------------------------
jsp页面写法:
<jsp:useBean id="co" class="tc.consolebean" />
<jsp:useBean id="crs" class="com.sun.rowset.CachedRowSetImpl" />
<%
crs=co.get_rsfarm("123");
while(crs.next())
{
String s3 = crs.getString("type");out.println("类型:"+s3);out.println("<BR>");
String s4 = crs.getString("amount");out.println("数量:"+s4);out.println("<BR>");
String s5 = crs.getString("fx");out.println("数量:"+s5);out.println("<BR>");
}
crs.close();
%>