• 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

insert problem to db2 tables from jsp page,please help very urgent

 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi everyone

i have problem ....... i m trying to insert data which is in jsp page int bale but it is not happening

my problem scenario is:

i have one jsp page ,in which i m displaying data from one table say table1 ,like this
<%try
{

stmt = con.createStatement();
String strsql2 ="select auc_ref_id,item_ref_id,'MT',1,0,10,10,20 from item_master where AUC_REF_ID="+arefid;
//out.print("auc_ref_id"+auc_ref_id);
rsitem=stmt.executeQuery(strsql2);

while(rsitem.next())
{
/*---------------retreiving and displaying data from database-----------------------*/
item_ref_id=rsitem.getString("ITEM_REF_ID");
unit=rsitem.getString(3);
cunit=rsitem.getString(4);
mmpq=rsitem.getString(5);
emdfact=rsitem.getString(6);
inc1=rsitem.getString(7);
inc2=rsitem.getString(8);

//for(i = 0; i < columns; i++){
//unit[i] = rs.getString(3);
//}
//unitvect.add(unit);
// for(i = unitvect.size()-1 ; i >=columns; i--) {
// out.print(unitvect.elementAt(i) );
// }

out.print("<tr>");
out.print("<td align=center>"+arefid+"</td>");
out.print("<td align=center>"+item_ref_id+"</td>");
out.print("<td align=center><input type=text name=unittext id= unittext value="+unit+"></td>");
out.print("<td align=center><input type=text name=cunittext id=cunittext value="+cunit+"></td>");
out.print("<td align=center><input type=text name=maxmpqtext id=maxmpqtext value="+mmpq+"></td>");
out.print("<td align=center><input type=text name=emdtext id=emdtext value="+emdfact+"></td>");
out.print("<td align=center><input type=text name=inc1text id=inc1text value="+inc1+"></td>");
out.print("<td align=center><input type=text name=inc2text id=inc2text value="+inc2+"></td>");
out.print("</tr>");
flag=flag+1;
rowcount++;
//out.print("rowcount"+rowcount);
}
/*if submit button is clicked------------*/
if (request.getParameter("confirmyes") != null)
{



String unittext=request.getParameter("unittext");
out.print("unittext"+unittext);
String cunittext=request.getParameter("cunittext");
String maxmpqtext=request.getParameter("maxmpqtext");
String emdtext=request.getParameter("emdtext");
String inc1text=request.getParameter("inc1text");
String inc2text=request.getParameter("inc2text");
try
{
String sql2 ="INSERT into mpq_conversionu values (?,?,?,?,?,?)";
PreparedStatement pst = con.prepareStatement(sql2);
pst.setString(1, arefid);
pst.setString(2, item_ref_id);
pst.setString(3, unittext);
pst.setString(4, cunittext);
pst.setString(5, maxmpqtext);
pst.setString(6, emdtext);
numRowsChanged = pst.executeUpdate();
}

catch (Exception e)
{
out.println(e);
}
}

if(numRowsChanged!=0)
{
%>
<br>
<TABLE style="background-color: #E3E4FA;"
WIDTH="30%" border="1">
<tr><th>Data is inserted successfully
in database.</th></tr>
</table>

<%}


out.print("</table>");

rsitem.close();
}
catch(Exception ex)
{
System.out.println(ex);
}
}
%>


submit button

no wif user want to edit he can edit the row .and here i m getting problem.after editing and submitting only first row is getting insert on table2
which has a same structure like table 1
 
Bartender
Posts: 2856
10
Firefox Browser Fedora Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Firstly please EaseUp a bit.

then please UseCodeTags. Unformatted code is hard to read and interpret.

Also it is not a good practice to write that big scriptlet in a JSP.

Please take some time to read the ask good questions link below.

Hope this helps
 
reply
    Bookmark Topic Watch Topic
  • New Topic