【发布时间】:2011-11-24 15:21:30
【问题描述】:
阅读以下代码:
public class selectTable {
public static ResultSet rSet;
public static int total=0;
public static ResultSet onLoad_Opetations(Connection Conn, int rownum,String sql)
{
int rowNum=rownum;
int totalrec=0;
try
{
Conn=ConnectionODBC.getConnection();
Statement stmt = Conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
String sqlStmt = sql;
rSet = stmt.executeQuery(sqlStmt);
total = rSet.getRow();
}
catch(Exception e)
{
System.out.println(e.getMessage());
}
System.out.println("Total Number of Records="+totalrec);
return rSet;
}
}
以下代码不显示实际总数:
total = rSet.getRow();
我的 jTable 在 jTable 中显示 4 条记录,但总数 = 0;当我通过调试评估时,它显示:
total=(int)0;
而不是总数=(int)4 如果我使用
rSet=last(); above from the code total = rSet.getRow();
然后 total 显示准确的值 = 4 但 rSet 不返回任何内容。那么 jTable 是空的。 更新我!
【问题讨论】:
-
因为
totalrec从未被使用过?