ResultSet: Exception: set type is TYPE_FORWARD_ONLY — why?

后端 未结 9 1378
春和景丽
春和景丽 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:43

    You can only do this with a resultset that is of type TYPE_SCROLL_SENSITIVE, which is defined as "The constant indicating the type for a ResultSet object that is scrollable and generally sensitive to changes made by others."

    You need to do something like the following ...

    Statement statement = 
     connection.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,
        ResultSet.CONCUR_READ_ONLY);
    

提交回复
热议问题