data parsing from a file into java and then into a mysql database

后端 未结 5 1514
借酒劲吻你
借酒劲吻你 2021-01-24 08:43

I have .Data file given in the above format . I am writing a program in java that will take the values from the .data file and put it in the buffer. MY java program is connected

5条回答
  •  温柔的废话
    2021-01-24 09:20

    The data is in CSV format, so use a CSV library to parse the file and then just add some JDBC code to insert this into database.

    Or just call MySQL CSV import command from Java:

    try {
        // Execute a command with arguments
        String command = "mysqlimport [options] db_name textfile1 [textfile2 ...]";
        Process child = Runtime.getRuntime().exec(command);
    
    } catch (IOException e) {
    }
    

提交回复
热议问题