我必须向数据库输入一些数据,请参阅我的代码。我在两次执行插入查询时遇到问题。 所以我想要一个包含字符串和ArrayList的for循环。
public static ArrayList<String> ApplicationPackageList = new ArrayList<String>();
public static ArrayList<String> ApplicationList = new ArrayList<String>();
.
.
.
for (String r : ApplicationPackageList ) {
DB.insertStmt.bindString(1, URLDecoder.decode(r));
DB.insertStmt.executeInsert();
}
for (String s : ApplicationList) {
// DB.insertStmt.bindString(1, URLDecoder.decode(r));
DB.insertStmt.bindString(2, URLDecoder.decode(s));
DB.insertStmt.executeInsert();
}
答案 0 :(得分:0)
List newList - new ArrayList();
newLIst.addAll(ApplicationList);
newLIst.addAll(ApplicationPackageList );
现在迭代newList
,但不会对性能产生任何正面影响,
答案 1 :(得分:0)
for(int i=0; i<ApplicationList.size() && i< ApplicationPackageList .size(); i++){
DB.insertStmt.bindString(1, URLDecoder.decode(ApplicationList.get(i)));
DB.insertStmt.bindString(2, URLDecoder.decode(ApplicationPackageList.get(i)));
DB.insertStmt.executeInsert();
}