日期:2014-05-18 浏览次数:20824 次
给8楼补充下 有些字符串 需要加单引号
String sqlStr = "";
String abcString="4,开,1,222,222,CJ:5,开,1,333,333,CJ:6,开,1,444,444,CJ:24,开,1,999,999,KZ:25,开,1,888,888,KZ";
String[] obj1 = abcString.split(":");
for(int i=0; i<obj1.length;i++){
Object[] obj2 = obj1[i].split(",");
sqlStr = "insert into xxxtable(param1,param2,param3,param4,param5,param6) values("+obj2[0]+",'"+obj2[1]+"',"+obj2[2]+","+obj2[3]+","+obj2[4]+",'"+obj2[5]+"');";
System.out.println(sqlStr);
}
给8楼补充下 有些字符串 需要加单引号
String sqlStr = "";
String abcString="4,开,1,222,222,CJ:5,开,1,333,333,CJ:6,开,1,444,444,CJ:24,开,1,999,999,KZ:25,开,1,888,888,KZ";
String[] obj1 = abcString.split(":");
for(int i=0; i<obj1.length;i++){
Object[] obj2 = obj1[i].split(",");
sqlStr = "insert into xxxtable(param1,param2,param3,param4,param5,param6) values("+obj2[0]+",'"+obj2[1]+"',"+obj2[2]+","+obj2[3]+","+obj2[4]+",'"+obj2[5]+"');";
System.out.println(sqlStr);
}