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

To store multiple data in ResultSet

 
Subhradip Podder
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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;
Class.forName("oracle.jdbc.driver.OracleDriver");
con=DriverManager.getConnection("jdbcracle:thin:@172.16.90.139:1531:PROD","apps","apps");
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++)
{
ps.setString(1,kys[i]);
}

rs=ps.executeQuery();
while(rs.next())

{%>
<tr>
<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>
</tr>
<%}
%>
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic