my dog learned polymorphism*
The moose likes JDBC and the fly likes writing below read file to database Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » JDBC
Reply locked New topic

writing below read file to database

Nash kumar

Joined: Sep 23, 2012
Posts: 20
I am JAVA beginner. I am reading excel file using apachi POI and would like the results to be saved on to database. I read the excel file using below code and it display the code in console correctly.

I would like to write the code to Database and save all the data in a database. "stringCellValue" contains the data. How can I save the data to variables in order to save in Database?

Jeanne Boyarsky
internet detective

Joined: May 26, 2003
Posts: 30130

I'm not sure exactly what you mean since stringCellValue is already a variable.

You will need to use JDBC to write to the database. The first step is to decide what the table you will be writing to looks like. Will it have a BLOB type and store the whole Excel file? Or a bunch of cells of different types? Or something else? There isn't a right or wrong to this. It depends on what is in your file and why you are writing to the database.

[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Nash kumar

Joined: Sep 23, 2012
Posts: 20
I am uploading an excel file that has particular format. It has 11 columns and I want to read that excel and copy the columns to database except the heading. Database has below structure in ms-server 2008 and Excel has same number of columns and in that order.

If I print the data from above code, I'll get below output. Please help me in storing the below code to database.

[EMP_ID] [int] NOT NULL,
[FNAME] [nvarchar](40) NULL,
[LNAME] [nvarchar](40) NULL,
[CATEGORY] [nvarchar](40) NULL,
[DEPARTMENT] [nvarchar](40) NULL,
[JTITLE] [nvarchar](40) NULL,
[REASON] [nvarchar](40) NULL,
[LMANAGER] [nvarchar](40) NULL,
[END_DATE] [date] NULL,
Wendy Gibbons

Joined: Oct 21, 2008
Posts: 1107

This is a duplicate of the post in beginning java, and as in there you say you know how to write JDBC statement ok, i am locking this one.
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
subject: writing below read file to database
Similar Threads
How to import data from Excel sheet to database using java??
Java Code to export data to Excel
Apache POI column Iternator
reading multiple sheets using apache POI
save Excel data to database