File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

save Excel data to database

 
Nash kumar
Greenhorn
Posts: 20
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am a java beginner. I have the below file that reads excel file. Excel file has nine columns and I created a DB Table with 9 columns. I would like to read the excel file except the first row and write to database table. How to achieve this.



 
J. Kevin Robbins
Bartender
Pie
Posts: 1605
15
Chrome Firefox Browser jQuery Linux MySQL Database Netbeans IDE
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There are probably several ways to do this, but personally, I would create a JavaBean that represents each of the columns in your database record, populate that bean with the values you've pulled from the spreadsheet, and then pass that bean to a DAO that will do the insert or update.

That's just my two cents worth. I'll be interested in seeing what other solutions are recommended.
 
Paul Clapham
Sheriff
Pie
Posts: 20163
24
MySQL Database
  • 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, there are many different ways of arranging for your data to be written to a database.

But none of those ways are going to care that you got that data from an Excel spreadsheet. In other words, the fact that your data came from Excel is irrelevant. Once you've got it out of Excel, just pick one of those ways and write the data to the database.

If you don't know any ways of writing to a database, let me recommend the JDBC tutorial.
 
Nash kumar
Greenhorn
Posts: 20
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank for the reply. I know how to use JDBC to insert values. Please help me how to save each cell value into a variable in order to insert them. Thank you.
 
J. Kevin Robbins
Bartender
Pie
Posts: 1605
15
Chrome Firefox Browser jQuery Linux MySQL Database Netbeans IDE
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What have you tried so far? Exactly what are you not clear on?

Show us some code. I think we've given you enough to at least take a stab at it.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic