File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases 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
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
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
author & internet detective

Joined: May 26, 2003
Posts: 33127

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.

[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, 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.
I agree. Here's the link:
subject: writing below read file to database
It's not a secret anymore!