Java implementation calls the Jdbctemplate.batchupdate method batch update __java

Source: Internet
Author: User
1, prepare the parameter private list<object[]> Preparparam (idatalist ret) {
Preparing to enter a parameter
list<object[]> paramlist = new arraylist<> ();
for (int i = 0; i < ret.size (); i++) {
Idata detail = Ret.getdata (i);
string[] arr = new string[6];
arr[0] = detail.getstring ("Orderdetailid");
arr[1] = detail.getstring ("ClientId");
arr[2] = detail.getstring ("Foodid");
arr[3] = detail.getstring ("Foodname");
arr[4] = detail.getstring ("Pictureurl");
arr[5] = detail.getstring ("num");
Paramlist.add (arr);
}
return paramlist; 2, calling the DAO layer method private void insertintotemptable (idata param, idatalist ret) throws Exception {
if (Common. IsNull (param.getstring ("ClientId")) {
throw new Customexception ("Dining machine ID cannot be empty");
}
if (ret.size () <= 0) {
throw new Customexception ("The meal machine does not have your desirable meal");
}
According to Param's dining machine ID, delete the current shipping record of this meal machine
Orderdao.deletebyclientid (param);
Insert the current shipping record
Orderdao.insertshipment (Preparparam (ret)); 3, the DAO layer method implements the public void Insertshipment (list<object[]> params) {
String sql = "INSERT into mp_client_shipment (\ n" +
"\ t order_detail_id, \ n" +
"\ t client_id, \ n" +
"\ t food_id, \ n" +
"\ t food_name, \ n" +
"\ t URL, \ n" +
"\ t num, \ n" +
"\ t created \ n" +
") \ n" +
"VALUES \ \" +
"\ t (?,?,?,?,?,?, now ())";
Jdbctemplate.batchupdate (sql, params);
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.