This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
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 The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Databases » JDBC
Reply locked New topic
Author

writing below read file to database

Nash kumar
Greenhorn

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
Marshal

Joined: May 26, 2003
Posts: 30356
    
150

Nash,
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
Greenhorn

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.



CREATE TABLE [dbo].[BULK_ACCESS](
[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,
[START_DATE] [date] NULL,
[END_DATE] [date] NULL,
[PROCESS_ID] [int] NULL
Wendy Gibbons
Bartender

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.
 
jQuery in Action, 2nd edition
 
subject: writing below read file to database