Meaningless Drivel is fun!*
The moose likes JDBC and the fly likes Will Select Statement work with Prepared Statment? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Will Select Statement work with Prepared Statment?" Watch "Will Select Statement work with Prepared Statment?" New topic
Author

Will Select Statement work with Prepared Statment?

asif kilwani
Greenhorn

Joined: Dec 04, 2001
Posts: 9
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


regards,<BR>Asif Kilwani
Jamie Robertson
Ranch Hand

Joined: Jul 09, 2001
Posts: 1879

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

Joined: Dec 04, 2001
Posts: 9
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
 
 
subject: Will Select Statement work with Prepared Statment?