Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Will Select Statement work with Prepared Statment?

 
asif kilwani
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The situation is that, i have a demo shopping cart, in which user click on checkbox(es) to add item(s) in his/her cart. I retrieve all checkbox(es) value from Form & insert it in a array object. That array object then transfer into Session.
However i m trying to make a Select statment which pick those prod no. which is in array object.
for example:
"Select * from product where prodno = " + ProdNo[i]
Something like that....but i m not sure about this query...
------------------
regards,
Asif Kilwani
 
Jamie Robertson
Ranch Hand
Posts: 1879
MySQL Database Suse
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Looks like this case is an excellent candidate for a PreparedStatement(looks like you are going to loop to get the array values):

Jamie
 
asif kilwani
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I tried your code..but if i don't insert while(rs.next()) after ResultSet rst = ps.executeQuery() it gives me "Invalidate Cursor State"
and i also noticed that if array contain two or three values, it gives me same error.
In George Reese Book, he used same stament but place CONCUR_READ_ONLY.
PreparedStatement stmt = con.prepareStatement("Select * from prodno Where prodno =?", ResultSet.CONCUR_READ_ONLY);
but that code gave me error...
how i can maintain the multiple ResultSet?

------------------
regards,
Asif Kilwani
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic