• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

uploading csv file into mysql database using jsp

 
preethi Ayyappan
Ranch Hand
Posts: 518
  • Mark post as helpful
  • send pies
  • 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
 
Rob Spoor
Sheriff
Pie
Posts: 20512
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • 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.
 
manoj r patil
Ranch Hand
Posts: 181
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic