方法一:
Statement stmt=con.createStatement();
//统计表中的记录条数
ResultSet rs1=stmt.executeQuery("select * from login");
int k=0;
while(rs1.next()){
k =k+1;
}
System.out.println( k );
rs1.close();
方法二:
Statement stmt=con.createStatement();
//获取记录总数
String strSQL = "select count(*) from login";
ResultSet sqlRst =stmt.executeQuery(strSQL);
//执行SQL语句并取得结果集
sqlRst.next(); //记录集刚打开的时候,指针位于第一条记录之前
int RowCount = sqlRst.getInt(1);
System.out.println(RowCount);
sqlRst.close(); //关闭结果
Statement stmt=con.createStatement();
//统计表中的记录条数
ResultSet rs1=stmt.executeQuery("select * from login");
int k=0;
while(rs1.next()){
k =k+1;
}
System.out.println( k );
rs1.close();
方法二:
Statement stmt=con.createStatement();
//获取记录总数
String strSQL = "select count(*) from login";
ResultSet sqlRst =stmt.executeQuery(strSQL);
//执行SQL语句并取得结果集
sqlRst.next(); //记录集刚打开的时候,指针位于第一条记录之前
int RowCount = sqlRst.getInt(1);
System.out.println(RowCount);
sqlRst.close(); //关闭结果