1

I have Java code that creates a MySQL database connection, and then processes a text file line-by-line. For each line (string), it parses it and creates a PreparedStatement that gets executed. The PreparedStatement inserts a new entry in a table in the database that I connected to.

My file contains thousands of lines, and I get this error: java.sql.SQLException: java.lang.OutOfMemoryError: Java heap space. How do I do this kind of operation more memory-efficiently? I've read about making a batch of MySQL statements and then executing the batch. Would that be helpful for my situation?

Software Dev
  • 910
  • 3
  • 10
  • 27

0 Answers0