Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

A little help

 
Ryan Raina
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Joshua Barrett
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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

 
Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic