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