Solved

CURSOR STATE NOT VALID

Posted on 2004-09-28
14
859 Views
Last Modified: 2012-06-27
I am using the following result set and prepared statement.  The update query works, but the a "CURSOR STATE NOT VALID"
exception occurs and the rest of my code is ignore. Thanks in advance to anyone that can help.

String updateDb2Query = "UPDATE tstdtatst.A767040A set ORCPDT = '"+bReqCompDate+"', ORFL = '"+flag+"', ORACTN = '"+action+"', ORFIH = "+frontInsideHeight+",ORRIH = "+rearInsideHeight+",ORFLRT="+floorRate+",ORLNID="+lineSplit+", ORDATE='yyyy-mm-dd',ORGDTE='yyyy-mm-dd', ORTPRC="+bTotal+", ORTCST="+bTotalCost+", ORTMRG="+bTotalMargin+", ORQTY="+bTotalQty+",ORMODL='"+bModel+"',ORCO='"+bPlant+"',ORSLSF='"+salesfname+"', ORSLSL='"+saleslname+"', ORCUST="+customerJdeNum+", ORPRCD='"+productCode+"',ORDAUT='"+discountNumber+"',ORUSER='"+salesmanId+"' where ORGORN = "+oracleId+"";
pUpdateDb2Query = db2.prepareStatement(updateDb2Query, ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
rsUpdateDb2Query = pUpdateDb2Query.executeQuery();
rsUpdateDb2Query.close();  pUpdateDb2Query.close();
0
Comment
Question by:gdlp2004
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 5
  • 3
14 Comments
 
LVL 37

Expert Comment

by:zzynx
ID: 12170055
Make

      pUpdateDb2Query.executeQuery();


     pUpdateDb2Query.updateQuery();

and see if it's better


0
 
LVL 37

Expert Comment

by:zzynx
ID: 12170067
I mean t

       pUpdateDb2Query.executeUpdate();

of course ;°)
0
 
LVL 30

Expert Comment

by:Mayank S
ID: 12170078
Also, I think that you can do away with the rsUpdateDb2Query altogether. Just make it:

pUpdateDb2Query.updateQuery () ;
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 30

Expert Comment

by:Mayank S
ID: 12170089
>> pUpdateDb2Query.executeUpdate();

Copied from zzynxie's ;-) do the correction as he said.
0
 

Author Comment

by:gdlp2004
ID: 12170206
The compiler does not recognize the executeUpdate method.  Is it because I used ResultSet.CONCUR_READ_ONLY in my prepared statement.
0
 
LVL 37

Expert Comment

by:zzynx
ID: 12170281
>> The compiler does not recognize the executeUpdate method
??? It shoulc
http://java.sun.com/j2se/1.4.2/docs/api/java/sql/Statement.html#executeUpdate(java.lang.String)
0
 
LVL 30

Expert Comment

by:Mayank S
ID: 12170378
>> Is it because I used ResultSet.CONCUR_READ_ONLY in my prepared statement.

No. What code are you using? Can you post it? I'm sure something else is wrong.
0
 
LVL 37

Accepted Solution

by:
zzynx earned 500 total points
ID: 12170429
Replace the line

      rsUpdateDb2Query = pUpdateDb2Query.executeQuery();

of your original code by

      pUpdateDb2Query.executeUpdate();
0
 

Author Comment

by:gdlp2004
ID: 12170435
The code is in the question statement.
0
 
LVL 37

Expert Comment

by:zzynx
ID: 12170454
>> The code is in the question statement.
The original, yes.
But we can't see where you placed the executeUpdate() statement in the changed code.
0
 

Author Comment

by:gdlp2004
ID: 12170484
OH, sorry!
0
 

Author Comment

by:gdlp2004
ID: 12170549
String updateDb2Query = og query
pUpdateDb2Query = db2.prepareStatement(updateDb2Query, ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
//rsUpdateDb2Query = pUpdateDb2Query.executeUpdate();
//updateDb2Query.executeUpdate();
//rsUpdateDb2Query.close();  pUpdateDb2Query.close();
pUpdateDb2Query.executeUpdate();

Here is the new code and it compiles. I am testing it now.
0
 

Author Comment

by:gdlp2004
ID: 12170638
The new code works.  Thank you
0
 
LVL 37

Expert Comment

by:zzynx
ID: 12173235
>> The new code works.  Thank you
Great. You're welcome
Thanks for accepting
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Facing this issue for maven proxy setting 2 27
Is Applet the way to go for my drag and drop system? 8 35
wild fly 8 startup error 2 41
Java List 4 40
For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question