If you are using Java8 or + version, JDBC and MySql8 and facing this issue then try this:
Add parameter to connection string:
jdbc:mysql://localhost:3306/tempDB?allowLoadLocalInfile=true
Also, set
local_infile = 1
in my.cnf file.
The latest version of mysql-java-connector might be wont allow directly to connect to local file. So with this parameter, you can able to enable it. This works for me.