Wrapping the SQLException
into an IOException
is a valid solution, because you are reading from a file (input) and writing to a database (output). The root cause of the IOException
would be the SQLException
.
You are correct though on the documentation, since it only mentions that the LineProcessor
is meant to be used with the readLines
methods. It doesn't explicitly say what behaviour is expected when an exception occurs. The documentation of readLines
, however, mentions that an IOException
should be thrown when an I/O error occurs.
Note that the LineProcessor
is also designed to be able to collect a result and return it using the LineProcessor#getResult
method, so you can always fully read the file first and return a result (if your files aren't too big). This will allow you to split the responsibilities of reading/processing the lines and the insertion of the data in your database.