This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
saswat rashmi
Greenhorn
Posts: 14
  • 0
  • Mark post as helpful
  • send pies
  • 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
 
Amit Ghorpade
Bartender
Posts: 2851
10
Fedora Firefox Browser Java
  • 0
  • Mark post as helpful
  • send pies
  • 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
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic