0

I'm parsing a large text file to add it into mySQL database, the file is more than 10K lines, each lines with more than 20 columns (line seperated by ",").

Before I start coding, I wanted to know which is the best way (in term of memory and execution time) between those two solutions :

  1. The easy way : Line by line

Adding row by row (more than 10K insert into) : The easiest way

  1. Complicated way

Parsing the whole file, creating ArrayList for each column, then inserting all the data in only one statement.

Does the "complicated way" save me a lot in the execution time ?

Thanks

Hamza Amami
  • 94
  • 4
  • 21

1 Answers1

0

Thanks to the solutions of @Gordon Linoff I was able to do it :

The request to execute in Java was :

LOAD DATA LOCAL INFILE 'file.txt' INTO TABLE TableName FIELDS TERMINATED BY ';';
Hamza Amami
  • 94
  • 4
  • 21