This week's book giveaway is in the Design forum.
We're giving away four copies of Building Microservices and have Sam Newman on-line!
See this thread for details.
The moose likes JSP and the fly likes To store multiple data in ResultSet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Building Microservices this week in the Design forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "To store multiple data in ResultSet" Watch "To store multiple data in ResultSet" New topic

To store multiple data in ResultSet

Subhradip Podder
Ranch Hand

Joined: Aug 27, 2007
Posts: 36
HI All,

Can any body help me to say what is process to store multiple data with ResultSet.

I want to write a code that shows multiple rows, selected by the previous jsp page, but i'm fail. It shows only one row in current page whether i select multiple rows in previous page.

My code is following: -

<% PreparedStatement ps=null;
Connection con=null;
ResultSet rs=null;
int m=0;
String[] kys= request.getParameterValues("pkey");

ps=con.prepareStatement("SELECT distinct a.vendor_id,a.vendor_name,b.pan_no FROM po_vendors a,JA_IN_VENDOR_TDS_INFO_HDR b "+
"WHERE a.vendor_id=b.vendor_id and a.vendor_id=?");
for(int i=0;i<kys.length;i++)


<td><input type=checkbox name=pkey value="<%= rs.getString(1) %>" /> </td>
<td><%= rs.getString(2) %> </td>
<td><%= rs.getString(3) %> </td>
<td><input type=text name=s_name value="" > </td>
Ben Souther

Joined: Dec 11, 2004
Posts: 13410

Your code is looping through the form parameters but it's writing them all to the same statement parameter.

Each iteration is writing to the statement's "1" parameter.

Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
I agree. Here's the link:
subject: To store multiple data in ResultSet
It's not a secret anymore!