The main goal is show how to import data from a comma delimited file to a Postgres Database.
In this project we use a Spring Batch to import a comma delimited file into a Postgres table. Spring Batch is a very powerfull tool with many capabilities. Check Spring Batch documentation for more info.
- Start your servers instances with Docker. Open the terminal / command prompt, go to the application folder and type:
docker-compose up -d
- Open another terminal, go to the application folder/target and type:
docker exec -it postgres bash OR docker exec -it <container id> bash
- Once inside, login into Postgres server:
psql -d testdb -U postgres
- Checking if table is empty OR not exist:
SELECT * FROM person;
- Open another terminal, go to the application folder/target and type:
java -jar importing-0.0.1-SNAPSHOT.jar --file.input=..\src\main\resources\idNomCpf.txt
- Return to MySQL terminal and type:
SELECT * FROM person;