[CONJ-986] How to LOAD DATA INFILE since 3.0.0? Created: 2022-06-27  Updated: 2022-08-17  Resolved: 2022-07-20

Status: Closed
Project: MariaDB Connector/J
Component/s: 2.7 compatibility, documentation
Affects Version/s: 3.0.5
Fix Version/s: 3.0.7

Type: Bug Priority: Major
Reporter: member sound Assignee: Diego Dupin
Resolution: Fixed Votes: 0
Labels: None


 Description   

Please provide samples how to migrate `MariaDbStatement.setLocalInfileInputStream` from 2.7.5 to 3.x

The docs still show the deprecated class:
https://github.com/microsoft/mariadb-connector-j/blob/master/documentation/use-mariadb-connector-j-driver.creole#jdbc-api-implementation-notes

The old way was neat for just loaded CSV data from *memory* without an intermediate file into a database, as follows:

        PreparedStatement st = con.prepareStatement("LOAD DATA LOCAL INFILE '' INTO TABLE my_table FIELDS TERMINATED BY ';'");
 
        if (st.isWrapperFor(MariaDbStatement.class)) {
            MariaDbStatement mariaDbStatement = statement.unwrap(MariaDbStatement.class);
            mariaDbStatement.setLocalInfileInputStream(new ByteArrayInputStream(csv.getBytes()));
        } 
 
        st.executeBatch();

How can the same be achieved since MariaDbStatement was dropped?



 Comments   
Comment by Diego Dupin [ 2022-06-27 ]

This functionnality was initially done to avoid a security risk (fake server in the middle), problem that has been solve since.
So this wasn't part of 3.0 rewrite.
But as you indicate this is a feature as well permitting to stream the file data. This will be corrected in next release

Comment by member sound [ 2022-08-17 ]

Please, if fixed, update the docs (https://github.com/microsoft/mariadb-connector-j/blob/master/documentation/use-mariadb-connector-j-driver.creole#jdbc-api-implementation-notes) how to `LOAD DATA` since 3.0.7.

Generated at Thu Feb 08 03:19:46 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.