ResultSet: Exception: set type is TYPE_FORWARD_ONLY — why?

后端 未结 9 1349
春和景丽
春和景丽 2020-12-15 07:08

I have very simple code:

pstat=con.prepareStatement(\"select typeid from users where username=? and password=?\");             
pstat.setString(1, username);         


        
9条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-15 07:23

    the rowCount variable is not necessary . you are performing two loops on the rs . only the second loop is necessary to get the number of rows which is done by this part of code:

     while (rs.next()){
     typeID=rs.getInt(1); //typeID is the number of rows in the ResultSet
    }
    

提交回复
热议问题