1

is it possible?? that

public interface TestRepository extends JpaRepository<Test, Long> {
    @Query("LOAD DATA LOCAL FILE ?1 INTO ......")
    public void loadCsv(String filePath);
}

because I have to move a lot of data(1M~ rows) to mysql table.

I found some ways for moving data and I am sure LOAD query is fastest. if any guys have any way for solving this problem, please give me advice!

thanks. :)

5
  • 1
    Yes you can do native query but not this way. Commented Feb 13, 2017 at 16:32
  • how to use native query with jpa naturelly? Commented Feb 14, 2017 at 0:34
  • I also got the same issue. I tried doing the following: @Query (value="LOAD DATA LOCAL INFILE 'C:/Users/tester/Documents/transaction_data.txt' INTO TABLE tbl_fin FIELDS TERMINATED BY ',' IGNORE 1 LINES", nativeQuery = true) public void bulkLoadData(); However I get the following error. java.sql.SQLException: ResultSet is from UPDATE. No Data. Looking this error up on google, forums have said that this is because the query is not returning data and it should be placed in a stored procedur but MySQL does not allow LOAD DATA commands in a stored procedure. Any thoughts? Commented Mar 12, 2018 at 14:19
  • @rm12345 did you find any solution ? we got same issue Commented Apr 22, 2019 at 20:54
  • @Krish you can see my solution on the following link: stackoverflow.com/questions/49209785/… Commented Apr 23, 2019 at 21:30

1 Answer 1

0

We need to pass the location of the file on DB server for below query, not the application server. @Query("LOAD DATA LOCAL FILE ?1 INTO ......")

Sign up to request clarification or add additional context in comments.

1 Comment

This is too short. Please elaborate how this solves the problem described in the question at the top of this page.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.