File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes uploading csv file into mysql database using jsp Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "uploading csv file into mysql database using jsp" Watch "uploading csv file into mysql database using jsp" New topic

uploading csv file into mysql database using jsp

preethi Ayyappan
Ranch Hand

Joined: Oct 04, 2007
Posts: 518
Hi all,

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

Rob Spoor

Joined: Oct 27, 2005
Posts: 20273

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.

How To Ask Questions How To Answer Questions
manoj r patil
Ranch Hand

Joined: Jun 06, 2002
Posts: 181
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.

love your job and not your company;
...because you never know when your company will stop loving you!
I agree. Here's the link:
subject: uploading csv file into mysql database using jsp
It's not a secret anymore!