user2632284
user2632284

Reputation: 11

Reading data from excel to query database

I am not exactly sure what the best approach here is. I am a novice programmer, trying to learn Java and I have a task I would like to complete. I have data in a Excel file. The Excel file has multiple columns. I need to take a the value from a particular column, use it to query a database. If the query returns null then add a value to a column, or mark it some how. If the the query returns a value then do nothing. Move to the next line.

anyone want to throw a noob a bone?

Upvotes: 1

Views: 973

Answers (3)

newuser
newuser

Reputation: 8466

Try to use Apache POI jar,

FileInputStream fis = new FileInputStream(FILE_NAME);
XSSFWorkbook workbook = new XSSFWorkbook(fis);
Sheet sheet = workbook.getSheet(READ_PARTICULAR_SHEET);

for (Row readRow : sheet)
{
    for (Cell readCell : readRow)
    {
       if (readCell.getCellType() == ANY_THING)
       {
         //anything you want
       }
    }
}

For reference here

Upvotes: 0

Franklin
Franklin

Reputation: 1801

I would look at using Apache POI for extracting the data from the excel file and MyBatis for database mapping/interaction.

Of course we can't write the code for you, but those two resources should give you a kickstart. Once you start writing the code, and you find yourself struggling, then I would post back here with code examples of what you're trying to achieve.

Upvotes: 0

lv0gun9
lv0gun9

Reputation: 621

See this. This is the answer I think. http://poi.apache.org/

Upvotes: 1

Related Questions