SQL结果集rs指针向上、移动第一条和移动最后一条记录报错。
与连接数据库JDBC有关系!
使用的ACCESS数据库。
Connection conn = null;// 数据库的连接
PreparedStatement stm = null;// SQL语句的装载器
ResultSet rs = null;// 结果集
String strSqlToNum="select * from 表名 ";
// (1)获取数据库连接
conn = DBManager.getConnection();
// (2)将SQL语句放到装载器中
stm = conn.prepareStatement(strSqlToNum);
rs = stm.executeQuery();
SQL指针rs只能向下移动,向上移动报错!
将stm = conn.prepareStatement(strSqlToNum);改为
stm1 = conn1.prepareStatement(strSqlToNum,ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
注意位置一定要放正确!
如有不足请大神提建议,谢谢!