Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 994
  • Last Modified:

CURSOR STATE NOT VALID

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
gdlp2004
Asked:
gdlp2004
  • 6
  • 5
  • 3
1 Solution
 
zzynxSoftware engineerCommented:
Make

      pUpdateDb2Query.executeQuery();


     pUpdateDb2Query.updateQuery();

and see if it's better


0
 
zzynxSoftware engineerCommented:
I mean t

       pUpdateDb2Query.executeUpdate();

of course ;°)
0
 
Mayank SAssociate Director - Product EngineeringCommented:
Also, I think that you can do away with the rsUpdateDb2Query altogether. Just make it:

pUpdateDb2Query.updateQuery () ;
0
Industry Leaders: 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!

 
Mayank SAssociate Director - Product EngineeringCommented:
>> pUpdateDb2Query.executeUpdate();

Copied from zzynxie's ;-) do the correction as he said.
0
 
gdlp2004Author Commented:
The compiler does not recognize the executeUpdate method.  Is it because I used ResultSet.CONCUR_READ_ONLY in my prepared statement.
0
 
zzynxSoftware engineerCommented:
>> 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
 
Mayank SAssociate Director - Product EngineeringCommented:
>> 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
 
zzynxSoftware engineerCommented:
Replace the line

      rsUpdateDb2Query = pUpdateDb2Query.executeQuery();

of your original code by

      pUpdateDb2Query.executeUpdate();
0
 
gdlp2004Author Commented:
The code is in the question statement.
0
 
zzynxSoftware engineerCommented:
>> 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
 
gdlp2004Author Commented:
OH, sorry!
0
 
gdlp2004Author Commented:
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
 
gdlp2004Author Commented:
The new code works.  Thank you
0
 
zzynxSoftware engineerCommented:
>> The new code works.  Thank you
Great. You're welcome
Thanks for accepting
0

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

  • 6
  • 5
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now