How do I read a large file from disk to database without running out of memory

后端 未结 6 884
野性不改
野性不改 2021-01-13 14:53

I feel embarrassed to ask this question as I feel like I should already know. However, given I don\'t....I want to know how to read large files from disk to a database witho

6条回答
  •  难免孤独
    2021-01-13 15:33

    I would just add using BufferedFileReader with the readLine method and doing exatcly in the fashion above.

    Basically understanding the resposnisbilties here.

    BufferedFileReader is the class reading data from file (buffe wise) There should be a LineReader too. CSVReader is a util class for reading the data assuming that its in correct format.

    SQlBulkCopy you are anywsay using.

    Second Option

    You can go to the import facility of database directly. If the format of the file is correct and thw hole point of program is this only. that would be faster too.

提交回复
热议问题