I have a program which parses some data out of HTML files and then does some computations on those files depending on the current date.
Since the parsing of the files takes a lot of time and they are not changing, I am now storing the data in an embedded H2 database and only parsing it if the data from that file is not in the database already. Otherwise I am just querying it from the database. Still the initial parsing and also when there are new files, it takes a lot of time.
So I am now at a point where I am trying to multithread the parsing. I want to do this using the ExecutorService and splitting the files into multiple tasks (one per file is probably not a good idea, probably going to be 10-20 tasks to use all cores). Now I don’t know, how I should implement the database access. Should I only have one connection and create the needed PreparedStatements per Task or should I use a connection pool (and also create the PreparedStatements per task) or something else?