This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes JSP and the fly likes insert problem to db2 tables  from jsp page,please help very urgent Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "insert problem to db2 tables  from jsp page,please help very urgent " Watch "insert problem to db2 tables  from jsp page,please help very urgent " New topic
Author

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

saswat rashmi
Greenhorn

Joined: Jul 31, 2007
Posts: 14
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

Joined: Jun 06, 2007
Posts: 2716
    
    6

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


SCJP, SCWCD.
|Asking Good Questions|
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: insert problem to db2 tables from jsp page,please help very urgent
 
Similar Threads
urgent !!!!how to access contents of list in jsp
Servlet not able to retrieve the values from jsp form
How to position fieldset?
inserting data to a table
page refresh problem