I have a ResultSet which brings more than 100 thousand data in total to be inserted, the problem is that my method inserts value by value in the query since there are fields that are empty, the method is as follows, only It's a portion:
try
{
rs.beforeFirst();
stmt = cnn.createStatement();
while(rs.next())
{
documentID = rs.getInt(1);
folio = rs.getString(5);
ficha = rs.getString(6);
nombre = rs.getString(7);
tipoArchivo = "PDF";
created = rs.getString(9);
created = created.substring(0, 19);
createdBy = rs.getString(10);
modified = rs.getString(11);
modified = modified.substring(0, 19);
modifiedBy = rs.getString(12);
String Qry = "INSERT INTO wfattxdoc(document_id, folio, ficha, nombre, document_created_date, document_createdby, document_modified_date, document_modifiedby)" +
" VALUES (" + documentID + ", " + "'" + folio + "'" + ", " + "'" + ficha + "'" + ", " + "'" + nombre + "'" + ", " +
"'" + created + "'" + ", " + "'" + createdBy + "'" + ", " +
"'" + modified + "'" + ", " + "'" + modifiedBy + "'" + ");";
stmt.executeUpdate(Qry);
}
stmt.close();
}
This causes it to go very slowly, and it takes more than 6 hours (I do not lie) to perform the whole process. My question is: Is there another more efficient way to insert thousands of records in a faster way? I do not get any error, the only problem is the slowness.