Win a copy of Secure Financial Transactions with Ansible, Terraform, and OpenSCAP this week in the Cloud/Virtualization forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Rob Spoor
  • Henry Wong
  • Liutauras Vilda
Saloon Keepers:
  • Tim Moores
  • Carey Brown
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
Bartenders:
  • Frits Walraven
  • Himai Minh
  • Jj Roberts

Invalid Cursor State Error

 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Guy i am trying to make a online test website on jsp and am using a servelet to handle the result but when i execute the code it shows a invalid cursor error and i seriously don't know what the hell is wrong help me out please !!!


Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("jdbc:odbc:mydata");
ResultSet rs;
PreparedStatement pst;
score=0;

for(int i=1;i<=num;i++)
{
ansgiven=request.getParameter(Integer.toString(i));
statement="select * from test where qnum = "+i ;
out.print(statement) ;
pst=con.prepareStatement(statement);
rs=pst.executeQuery();
ans=rs.getString("answer");
if(ans.equals(ansgiven))
{
score++;
}




}



The error is in this code only !!!
help me out please
 
Ranch Hand
Posts: 182
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Nishant,

You should move your cursor to the first record, then another and then another



Regards,
Fatih.
 
Nishant Vashisth
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i thought of that dude !!
but i want to check the result of the question as per their numbers so that i could keep track of which question is answered correct !!
can you help me with the full code !!
 
Nishant Vashisth
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i got it working thanks for the suggestion dude !!

moderators please close this topic !!
 
You will always be treated with dignity. Now, strip naked, get on the probulator and hold this tiny ad:
SKIP - a book about connecting industrious people with elderly land owners
https://coderanch.com/t/skip-book
reply
    Bookmark Topic Watch Topic
  • New Topic