@Test public void batchSaveUser() { }
@GetMapping("batchSave") public String batchSaveUser()throws Exception { String sql = "INSERT INTO user (USERNAME,PASSWORD) VALUES (?,?)"; List<Object[]> arrayList = new ArrayList<>(); for (int i = 0; i < 10; i++) { String[] arr = new String[2]; arr[0] = "longzhiran" + i; arr[1] = "123456" + i; arrayList.add(arr); } jdbcTemplate.batchUpdate(sql, arrayList); return "执行成功"; }
UserController { @GetMapping("batchSave") public String batchSaveUser()throws Exception { String sql = "INSERT INTO user (USERNAME,PASSWORD) VALUES (?,?)"; List<Object[]> arrayList = new ArrayList<>(); for (int i = 0; i < 10; i++) { String[] arr = new String[2]; arr[0] = "longzhiran" + i; arr[1] = "123456" + i; arrayList.add(arr); } jdbcTemplate.batchUpdate(sql, arrayList); return "执行成功"; } }
UserController { @GetMapping("batchSave") public String batchSaveUser()throws Exception { String sql = "INSERT INTO user (USERNAME,PASSWORD) VALUES (?,?)"; List<Object[]> arrayList = new ArrayList<>(); for (int i = 0; i < 10; i++) { String[] arr = new String[2]; arr[0] = "longzhiran" + i; arr[1] = "123456" + i; arrayList.add(arr); } jdbcTemplate.batchUpdate(sql, arrayList); return "执行成功"; }  }
UserController { @GetMapping("batchSave") public String batchSaveUser()throws Exception { String sql = "INSERT INTO user (USERNAME,PASSWORD) VALUES (?,?)"; List<Object[]> arrayList = new ArrayList<>(); for (int i = 0; i < 10; i++) { String[] arr = new String[2]; arr[0] = "longzhiran" + i; arr[1] = "123456" + i; arrayList.add(arr); } jdbcTemplate.batchUpdate(sql, arrayList); return "执行成功"; }  @GetMapping("createUserTable") String createUserTable(); @GetMapping("saveUserTest") String saveUserTest(); @GetMapping("batchSave") String batchSaveUser(); @GetMapping("add") String addUser(String userName, String passWord); @GetMapping("updateUserPassword") String updateUserPassword(int id, String passWord); @GetMapping("deleteUserById") String deleteUserById(int id); @GetMapping("getUserByName") List getUserByName(String userName); @GetMapping("getMapById") Map getMapById(Integer id); @GetMapping("getUserById") User getUserById(Integer id); @GetMapping("list") List<User> list(); }
UserController { @GetMapping("batchSave") public String batchSaveUser()throws Exception { String sql = "INSERT INTO user (USERNAME,PASSWORD) VALUES (?,?)"; List<Object[]> arrayList = new ArrayList<>(); for (int i = 0; i < 10; i++) { String[] arr = new String[2]; arr[0] = "longzhiran" + i; arr[1] = "123456" + i; arrayList.add(arr); } jdbcTemplate.batchUpdate(sql, arrayList); return "执行成功"; }  @GetMapping("createUserTable") String createUserTable(); @GetMapping("saveUserTest") String saveUserTest(); @GetMapping("batchSave") String batchSaveUser(); @GetMapping("add") String addUser(String userName, String passWord); @GetMapping("updateUserPassword") String updateUserPassword(int id, String passWord); @GetMapping("deleteUserById") String deleteUserById(int id); @GetMapping("getUserByName") List getUserByName(String userName); @GetMapping("getMapById") Map getMapById(Integer id); @GetMapping("getUserById") User getUserById(Integer id); @GetMapping("list") List<User> list();  }