Issue
I am using folowing mariadb to connect to a mysql :
<dependency> <groupId>org.mariadb.jdbc</groupId> <artifactId>mariadb-java-client</artifactId> <version>3.0.3</version> </dependency>
My problem is that I want to use local script. According to the mariadb connector documentation, this should be achievable using "setLocalInfileInputSream" as describe here : https://mariadb.com/kb/en/about-mariadb-connector-j/#jdbc-api-implementation-notes
But as describe, the Statement used should be a wrapper of MariaDbStatement. In my code the statement I use is of this class : class org.mariadb.jdbc.ClientPreparedStatement
Also the class MariaDbStatement is not in my class path, so I can’t even have the example coed compiling.
Here is an extract of my code. This code is an alternate version using the java mysql connector as I was not able to use the mariadb java client. Again, the main problem seems to be that I don’t have MariaDbStatement in my class path (to be used instead of JdbcStatement).
try (PreparedStatement stmt = con.prepareStatement(query)) {
stmt.clearParameters();
((JdbcStatement) stmt).setLocalInfileInputStream(stream);
stmt.execute();
} catch (SQLException e) {
e.printStackTrace();
}
Solution
The MariaDbStatement is not present anymore in the mariadb java connector since the 3.0.0 version.
It was deleted in this commit : https://github.com/mariadb-corporation/mariadb-connector-j/commit/e5e95ddfd6ceed7bce757a5b2521c61208e59700
The documentation seems outdated then.
Answered By – bloub
Answer Checked By – Dawn Plyler (BugsFixing Volunteer)