Home > front end >  How to get a whole row in a table and insert the data into the new table
How to get a whole row in a table and insert the data into the new table

Time:01-04

I from the background to make the "order" the data in this table are extracted out, going to click the "schedule" form now inserted the corresponding to the data table "deliver", no matter what operations are prompt failure, "tel can't be empty" is the reason, o you who help

JSP interface
<body>





Contact & lt;/th>
Address & lt;/th>
Ordering goods & lt;/th>
Time & lt;/th>
Delivery personnel & lt;/th>
Operation & lt;/th>









Arrange & lt;/button>







The Servlet code
If (param. EqualsIgnoreCase (" 1 "))
{
String tel=request. The getParameter (" order. Tel ");
String adress=request. The getParameter (" order. Adress ");
String type=request. The getParameter (" order type ");
String time=request. The getParameter (" order time ");
String num=request. The getParameter (" order. Num ");
AdminDao AdminDao=new AdminDao ();
Int value=https://bbs.csdn.net/topics/adminDao.inset (connection, tel and adress, type, time, num);
If (value> 0 {
The response. GetWriter (). Print (" & lt; Script language='javascript' & gt; Alert (' arrangements for success! ') & lt;/script>" );
The response. SetHeader (" refresh ", "0.05; URL=admmain. JSP ");
} else {
The response. GetWriter (). Print (" & lt; Script language='javascript' & gt; Alert (' arrangement failed! ') & lt;/script>" );
The response. SetHeader (" refresh ", "0.05; URL=admmain. JSP ");
}

}

The Dao code
Public int an inset (Connection Connection, String tel, String adress, String type, String time, String num) {//send a single
Int value=https://bbs.csdn.net/topics/-1;
PreparedStatement statement=null;
String SQL="insert into deliver (tel and adress, type, time, num) values (?,?,?,?,? ,? ,? ,? ,?) ";
Try {
The statement=connection. PrepareStatement (SQL);
Statement. SetString (1, tel);
The statement. SetString (2, adress);
The statement. SetString (3, type);
The statement. SetString (4, time);
The statement. SetString (5, num);
value=https://bbs.csdn.net/topics/statement.executeUpdate ();
}
The catch (SQLException ex)
{
Ex. PrintStackTrace ();
}
The finally
{
Try
{
If (the statement!=null) statement. The close ();
}
The catch (SQLException ex)
{
}
}
return value;
}

CodePudding user response:

I put the interface in the InsertServlet? Param InsertServlet=1 changed? Param=${order. Tel} watch on web pages can be normal access to the current row of tel, I thought is to get less than the data in the table to insert failure but it may not seem like it? Qaq bosses of save the children

CodePudding user response:


Long form
  • Related