So i have a code like this:
public static void ispisiSvakuDruguKnjigu(){
try{
Connection conn = getConnection();
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery("select * from knjiga");
while(true){
if(rs.next()){
System.out.println(rs.getString("id")+" "+rs.getString("naslov"));
rs.relative(2);
} else {
return;
}
}
} catch (Exception e){
e.printStackTrace();
}
}
That we are doing in a class that reads every 2nd book from a MySQL database, it is working properly on the class that im watching but on my PC it is showing me error like this:
java.sql.SQLException: Operation not allowed for a result set of type ResultSet.TYPE_FORWARD_ONLY.
EDIT First of all i want to thank you all for anwsers, i am a late learner, and a very big beginner at Java. I have managed to test it out and fix the code for it to work as intended based on your anwsers. My confusion mainly came that the course im watching and my code were exactly the same and it worked for them without having to do what i did. Thank you all for the patience again and sorry for confusion.
i changed this:
Statement stmt = conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY);