总行数 结果集 getRow 方法
阅读以下代码:
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;
}
}
folowing 代码 dos 不显示实际的总计:
total = rSet.getRow();
我的jTable在jTable中显示4条记录,但总数= 0;当我通过调试进行评估时,它显示:
total=(int)0;
而不是 total=(int)4 如果我使用
rSet=last(); above from the code total = rSet.getRow();
则 total 显示准确值 = 4,但 rSet 不返回任何内容。则 jTable 为空。更新我!