• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

To store multiple data in ResultSet

 
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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("jdbc:oracle: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>
<%}
%>
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic