Skip to Main Content

Java Database Connectivity (JDBC)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Why 'invalid cursor state' when Statement.executeQuery() returns nothing?

843859Jun 7 2006 — edited Jun 7 2006
Hi all..
I having problems to make some queries and I can't think anymore about what could be...

I understand that I will get a 'invalid cursor state' if I try to get some data from a empty ResultSet... but I'm receiving this error when I make the query...

Please, friends, take a look in my code and tell me what I'm doing wrong... please..

Thank you.

Fl�vio Henrique

this is a JButton's actionPerformed :
ResultSet rs, rs2;
        String  evento = "", local= "", periodoInicial= "", periodoFinal= "";
        if ( diaRepasse.getText().trim().length() > 0 ) {
            try {
                Statement st    = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);           
                Statement st2   = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
                rs = st.executeQuery(UtilDB.buscaEventosPorDiaRepasse(Integer.parseInt(diaRepasse.getText().trim())));
                while (rs.next()){
                    evento = rs.getString("c�digo");
                    local = rs.getString("local");
                    rs2 = st2.executeQuery(UtilDB.selecionaTitulosBaixados(evento, local));
                }
            }
            catch (Exception e){
                UtilDB.errosg(e);
            }
        }
The error occurs in :
                    rs2 = st2.executeQuery(UtilDB.selecionaTitulosBaixados(evento, local));
if the line above returnn nothing, I got the error, if returns records no problem...
the odd thing is: if the same occurs (returns nothing0 in the first executeQuery I do not get the error...

I dont think that methods "UtilDB.buscaEventosPorDiaRepasse(Integer.parseInt(diaRepasse.getText().trim()))" and "UtilDB.selecionaTitulosBaixados(evento, local)" is not necessary to post here, because they just returns a sql command.

Thank you in advance for ANY help/tip.

Fl�vio Henrique
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 5 2006
Added on Jun 7 2006
3 comments
221 views