Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <pre><code>try { FileInputStream file = new FileInputStream(new File("E://Imp/Details.xlsx")); XSSFWorkbook workbook = new XSSFWorkbook(file); XSSFSheet sheet = workbook.getSheetAt(0); Iterator&lt;Row&gt; rowIterator = sheet.iterator(); rowIterator.next(); while(rowIterator.hasNext()) { Row row = rowIterator.next(); //For each row, iterate through each columns Iterator&lt;Cell&gt; cellIterator = row.cellIterator(); while(cellIterator.hasNext()) { Cell cell = cellIterator.next(); //This will change all Cell Types to String cell.setCellType(Cell.CELL_TYPE_STRING); switch(cell.getCellType()) { case Cell.CELL_TYPE_BOOLEAN: System.out.println("boolean===&gt;&gt;&gt;"+cell.getBooleanCellValue() + "\t"); break; case Cell.CELL_TYPE_NUMERIC: break; case Cell.CELL_TYPE_STRING: list.add(cell.getStringCellValue()); break; } } name=row.getCell(0).getStringCellValue(); empid=row.getCell(1).getStringCellValue(); add=row.getCell(2).getStringCellValue(); mobile=row.getCell(3).getStringCellValue(); System.out.println(name+empid+add+mobile); ex.InsertRowInDB(name,empid,add,mobile); System.out.println(""); } file.close(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } public void InsertRowInDB(String name,String empid,String add,String mobile) throws SQLException{ Statement stmt=db.con.createStatement(); PreparedStatement ps=null; String sql="Insert into Employee(Name,EmployeeId,Address,ContactInfo) values(?,?,?,?)"; ps=db.con.prepareStatement(sql); ps.setString(1, name); ps.setString(2, empid); ps.setString(3, add); ps.setString(4, mobile); ps.executeUpdate(); System.out.println("Values Inserted Successfully"); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload