I have my java program to extract some useful data from some of the text files. Now I want that data should be put in the corresponding columns into the MySQL database. how can I do that? Please guide me.
Asked
Active
Viewed 229 times
-1
-
I want to use JPA too. – peeyush Nov 17 '18 at 04:22
-
Possible duplicate of [How to import data from text file to mysql database](https://stackoverflow.com/questions/13579810/how-to-import-data-from-text-file-to-mysql-database) – Abhinav Nov 17 '18 at 05:11
1 Answers
-1
You can create two Classes:
- DTO (Data Transfer Object)
- Entity
When you read the data from the text file, you can map it to your DTO class using jackson or google gson libraries. Once you create your DTO object by reading the text file, you can simply create objects of your entity class from it and call the save method of your jpa.

Mark Rotteveel
- 100,966
- 191
- 140
- 197

Abhishek Patyal
- 514
- 4
- 8