title: How do I upload a CSV file and then automatically insert the data into the DB?
body: <p>I have Java based Spring MVC application that also uses Spring security. I am using hibernate as an ORM tool for this web app.</p>
  
  <p>Following is my requirement -- </p>
  
  <p>User will have ability to upload a CSV file using a web browser. The format of the CSV file is known to have following 5 fields:</p>
  
  <pre>
  userId, location, itemId, quantity, tranDate
  001, NY, 00A8D5, 2, 12/31/2012
  002, MN, 00A7C1, 10, 12/22/2012
  .
  .
  </pre>
  
  <p>like this there are about 100 rows.</p>
  
  <p>I am using Super CSV in the project:</p>
  
  <pre><code>private void readWithCsvBeanReader(String CSV_FILENAME) throws Exception {
  
      String CSV_FILENAME = "\\\\Serv01\\Files\\QueryResult.csv";
      //String CSV_FILENAME = "C:\\Files\\QueryResult.csv";
      ICsvBeanReader beanReader = null;
      try {
          beanReader = new CsvBeanReader(new FileReader(CSV_FILENAME),
                  CsvPreference.STANDARD_PREFERENCE);
  
          // the header elements are used to map the values to the bean (names
          // must match)
          final String[] header = beanReader.getHeader(true);
          // get Cell Processor
          final CellProcessor[] processors = getProcessors();
  </code></pre>
  
  <p>Here I am reading the contents of the CSV file and then using Hibernate, I am inserting it.</p>
  
  <p>This works fine as I am providing the CSV path locally or on the windows share.</p>
  
  <pre><code>String CSV_FILENAME = "\\\\Serv01\\Files\\QueryResult.csv";
  or via this:
  String CSV_FILENAME = "C:\\Files\\QueryResult.csv"; 
  </code></pre>
  
  <ol>
  <li><p>How can I achieve this requirement such that the CSV file path location will be provided by a button on the webpage using Spring MVC?</p></li>
  <li><p>Is it also possible to pick up the file automatically from a remote location such that I will upload the file in a FTP location and then the program can connect to the remote ftp location and process the file on a schedule?</p></li>
  </ol>
  
  <p>PS: I am new to file operations and if someone can point towards some article then it will be great.</p>