title: Java spring boot import csv into mysql using rest api
body: <p>I created API using spring boot to upload the CSV file using rest controller, I want to import the data into MySQL table while upload the csv to the server.</p>
  
  <p>I have mysql table called attendee as like below</p>
  
  <pre><code>id | event_id | name | email
  </code></pre>
  
  <p>User want to upload csv file from client app (angular 2) to server and need to import data into attendee table.</p>
  
  <p>CSV will be like this</p>
  
  <pre><code>name  | email
  John  , Doe
  </code></pre>
  
  <p>So I created REST API <code>events/&lt;event_id&gt;/attendee</code></p>
  
  <pre><code>@PostMapping(value = "/{id}/attendee")
  public ResponseEntity&lt;String&gt; uploadAttendee(@PathVariable Integer id,@RequestParam("file") MultipartFile file) {
  
      String message = "";
      try {
          storageService.store(file);
          files.add(file.getOriginalFilename());
  
          message = "You successfully uploaded " + file.getOriginalFilename() + "!";
  
  
         // Here I am to import into database 
  
  
          return ResponseEntity.status(HttpStatus.OK).body(message);
      } catch (Exception e) {
          message = "FAIL to upload " + file.getOriginalFilename() + "!";
          return ResponseEntity.status(HttpStatus.EXPECTATION_FAILED).body(message);
      }
  }
  </code></pre>
  
  <p>Can someone so me full Example of importing into database. I'm not much experienced in java spring framework. It will useful someone explain in detail.</p>