shared drive csv file load to Mssql table using spring

≯℡__Kan透↙ 提交于 2020-01-03 06:39:31

问题


I am searching for approach/ code base which can fulfill the below requirement.

  1. We have source file(formatted) in shared drive which has ~one million record count, this drive has new file every day with date prefix on it(eg: 02-12-2018_abcd.txt)

    2.While reading file from sharedrive location, if its any failure occuer it
    should not commit the sql insert.

    3.this job should run on schduled time.

I found the couple of approaches to read file from shared drive like jar to read, another approach is to copy the file from shared drive to local machine(on applicaion server) and do spring batch processing and other approach is using spring integration adapter, inbount channel etc.

Please suggest and the best approach and spring code base/ git code for the same. Thanks


回答1:


This is a typical use case where Spring Batch can help. You can have a first step (of type tasklet) that copies the file from the shared drive to the local machine and then a second step (of type chunk oriented tasklet) that reads the file and inserts data in the database.

You can find samples here: https://github.com/spring-projects/spring-batch/tree/master/spring-batch-samples



来源:https://stackoverflow.com/questions/52104181/shared-drive-csv-file-load-to-mssql-table-using-spring

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!