I have a MySQL Tomcat 9 application that frequently updates the database using LOAD DATA LOCAL INFILE
. Until now I have been using temporary files, but there are problems and I decided to move to in-memory streams and StatementImpl.setLocalInfileInputStream
.
There is enough information on this, including how the method moved to com.mysql.cj.jdbc.StatementImpl
, however the Statement
I get using Connection.createStatement()
is the Statement
interface implemented by org.apache.tomcat.dbcp.dbcp2.DelegatingStatement
. Underlying statement can be retrieved using getDelegate()
, however the original one is under additional layer of DelegatingStatement
. A monstrosity that works in these circumstances is
((com.mysql.cj.jdbc.StatementImpl)(((org.apache.tomcat.dbcp.dbcp2.DelegatingStatement)
((org.apache.tomcat.dbcp.dbcp2.DelegatingStatement)stetement).getDelegate())
.getDelegate())).setLocalInfileInputStream(inputStream);
I am concerned about sustinability of this solution, it is ugly and the interface might change again. Is there a better way of using setLocalInfileInputStream
?