原文出自:https://blog.csdn.net/seesun2012
sql
package com.seesun2012.com; /** * Java大批量修改、删除数据,按指定标识符分隔字符串 * * @author 张擎宇 * */ public class AppointSeparate { public static void main(String[] args) { //定义加入有一万条数据要被处理 int aa = 10000; String[] aaStr = new String[aa]; //获取每个id到String[]字符串数组中 for (int i = 0; i < aa; i++) { aaStr[i] = "" + i; splitStr(aaStr[i]); } } //分隔JSON数据源中的数据,此处使用split方法去掉“,”号 public static void splitStr(String id) { /** * * 将分隔开的数据保存至String[]数组中,如下几种转移字符必须加上"\\"做为判断转移符标志 * String.split("\\."); * String.split("\\|"); * String.split("|"); //将会分隔成一个一个的字符,而且包含空格在内 * */ String[] str = id.split(","); //接收分隔后的字符串数组长度 String[] strAt = new String[str.length]; //循环遍历得出结果 for (int i = 0; i < str.length; i++) { strAt[i] = "'"+ str[i] +"'"; //此时的strAt[]为,strAt['0'~'9999'],带上单引号 } for (String s : strAt) { //若是对数据库操做,大批量更新、删除操做 String sql = "select * from t_user where u_id=" + s; System.out.println(sql); } } }