Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
325 views
Welcome To Ask or Share your Answers For Others

1 Answer

等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...