• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

uploading csv file into mysql database using jsp

 
Ranch Hand
Posts: 518
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,

I need to upload a csv file into mysql database using jsp.Is it possible to do?

Thanks
 
Sheriff
Posts: 22784
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sure it is, but you need to split the problem into several smaller problems:

1) Upload the file. You can use Apache Commons FileUpload for that.

2) Reading and parsing the CSV file so you have better access to its columns. Check out Accessing File Formats. I myself have good experiences with opencsv.

3) Insert the data from the CSV file into your table. You will need JDBC or an abstraction layer for that.
 
Ranch Hand
Posts: 182
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
CSV file is nothing but a plain text file with comma separated values. There are quite a few csv parsers available on the net.

When you say "you want to upload csv file into mysql", do you want to suck the complete csv file as is and dump it into MySQL? You can use multipart request for that and can dump in the "text" column.

If you want to extract values out of that file, you can upload the file using multipart form data and then using csv parser at the server side, you can extract the values and save to database.
 
reply
    Bookmark Topic Watch Topic
  • New Topic