wood burning stoves 2.0*
The moose likes Java in General and the fly likes A little help Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "A little help" Watch "A little help" New topic
Author

A little help

Ryan Raina
Greenhorn

Joined: Jun 16, 2010
Posts: 28
Hi Friends i would like to have a little help!!
I have a situation that when a user uploads an excel the cells values need to persisted in the
database using insert querries in a for loop.
i am able to retrieve the cells values using Apache POI but
i donot know how to fire the querries
Kindly see my code below


what can i do to fire queries in database.??

Thanks in Advance
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41083
    
  43
If you aren't familiar yet with JDBC -the standard Java API for accessing databases- then that's where you should start. Do you know which DB you will be using?

As an aside, you should write POI code using the classes in the org.apache.poi.ss package, not the *hssf* or *xssf* packages. That way the code can handle binary files as well as XML files.


Ping & DNS - my free Android networking tools app
Joshua Barrett
Greenhorn

Joined: Sep 08, 2010
Posts: 27
You need to be more specific about the type of database you are using. I also assume you are familar with basic SQL

Also may I recommend you write a better title for your thread. Saying "A Little Help!" is not at all descriptive to your problem.
Ryan Raina
Greenhorn

Joined: Jun 16, 2010
Posts: 28
Well i guess that i wan't clear on my question
If you see these lines of code you will find out that i am getting values of the cells as a output.

for (int j = 0; j < cellStoreVector.size(); j++) {
XSSFCell myCell = (XSSFCell) cellStoreVector.elementAt(j);
st = myCell.toString();
Thread.sleep(500);
System.out.println(st); //prints the cell value for a row one by one
}



Now consider an example that there is an excel having header like name,address etc
the value of first cell on row 1 is under name and values of second cell is under address
on row 1.
Also database has these two columns
Now coming to the situation,
I need to fire some queries in database using insert statment
For example
Insert into tableNAme name,address values 'value of cell at row1 coloum1','value of cell at row1 coloum2'


ok now suppose there are lots of rows in the excel sheet
Then i have to do this same thing in a for loop.

so my question is this how should i approach to fire insert queries in a for loop
i have all the cell values in a list . how should i fire queries and also change the cell and column

 
 
subject: A little help
 
Similar Threads
Java Code to export data to Excel
Java API for MS Excel 2010
Read Excel values and store in to Database
excel sheet data insertion
How to read xls, xlsx and open office excel formats from java. Any pointers ? Kindly help.