Menu

Invalid Cursor State, but not for every ResultSet

Help
Tuan Pham
2016-12-01
2016-12-01
  • Tuan Pham

    Tuan Pham - 2016-12-01

    Hi every one, im trying to set a connection with a database with the help of ucanaccess then got an exception that looks like this

    Caused by: java.sql.SQLException: invalid cursor state: identifier cursor not positioned on row in UPDATE, DELETE, SET, or GET statement: ; ResultSet is empty
    

    here is my code snippet :

                try {   
                    String sql2 = "SELECT * FROM fit_article_code WHERE i_fit_article = " + Integer.toString(id);
                    rs2 = stm.executeQuery(sql2);
                    rs2.next();
                    CodeList a = new CodeList();
                    if (rs2.getString("s_code") != null){
                        a.addCode(rs2.getString("s_code"));
                        System.out.println(a);
                        article.setCode(a);
                    }
    
                } catch (Exception e2) {
                    e2.printStackTrace();
                }
    

    Here I am trying to print out the attribute Code of each object. I have around 2-3 hundreds objects and almost all of them were read just fine. Only for the 3 Objects the programm says there is an exception. I try to run the code again and again, everytime only the 3 cause the problem. I looked at my Database and everything seems normal for the 3 objects. Can some one explain to me what could be wrong here ? Thanks in advance!

     

    Last edit: Tuan Pham 2016-12-01
  • Tuan Pham

    Tuan Pham - 2016-12-01

    I have found the problem, please dont mind me, thanks :D

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.