This commit is contained in:
Gianpaolo Coro 2013-11-05 16:50:28 +00:00
parent b87996cb5e
commit 660561ff4a
1 changed files with 12 additions and 4 deletions

View File

@ -174,12 +174,12 @@ public class DatabaseUtils {
String[] row = values.get(i);
sb.append("(");
for (int j=0;j<row.length;j++){
sb.append("'"+row[j]+"'");
sb.append("'"+row[j].replaceAll("^'", "").replaceAll("'$", "")+"'");
if (j<row.length-1)
sb.append(",");
}
sb.append(")");
if (stopIndex%chunkSize==0){
if (stopIndex>0 && stopIndex%chunkSize==0){
DatabaseFactory.executeSQLUpdate(insertFromBuffer(table, columnsNames, sb), dbconnection);
stopIndex=chunkSize;
sb = new StringBuffer();
@ -189,8 +189,16 @@ public class DatabaseUtils {
}
if (stopIndex<valuesize-1){
List<String[]> sublist = values.subList(stopIndex+1, valuesize);
insertChunksIntoTable(table, columnsNames, sublist, chunkSize,dbconnection);
if (sb.length()>0){
// System.out.println(sb);
try{
DatabaseFactory.executeSQLUpdate(insertFromBuffer(table, columnsNames, sb), dbconnection);
}catch(Exception e){
System.out.println("Query:"+sb);
throw e;
}
}
}
}