Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to insert into database reading from excel sheet using java POI?
    text
    copied!<p>I'm reading the value from excel sheet using java POI and need to insert into database.I have string,numeric and date values from excel sheet as well as first fields are column header.</p> <pre><code>public class SimpleExcelReadExample { static Connection con1 = null; static Connection con3 = null; static PreparedStatement preparedstatement = null; static ResultSet resultset = null; int j = 0; public static void main(String[] args) { String fileName = "D:/Excel/Report.xls"; Cleartables.table_daily_report(); Vector dataHolder = read(fileName); saveToDatabase(dataHolder); } public static Vector read(String fileName) { Vector cellVectorHolder = new Vector(); try { FileInputStream myInput = new FileInputStream(fileName); POIFSFileSystem myFileSystem = new POIFSFileSystem(myInput); HSSFWorkbook myWorkBook = new HSSFWorkbook(myFileSystem); HSSFSheet mySheet = myWorkBook.getSheetAt(0); Iterator rowIter = mySheet.rowIterator(); while (rowIter.hasNext()) { HSSFRow myRow = (HSSFRow) rowIter.next(); Iterator cellIter = myRow.cellIterator(); Vector cellStoreVector = new Vector(); while (cellIter.hasNext()) { HSSFCell myCell = (HSSFCell) cellIter.next(); //System.out.println("read method"+myCell); cellStoreVector.addElement(myCell); } cellVectorHolder.addElement(cellStoreVector); } } catch (Exception e) { e.printStackTrace(); } return cellVectorHolder; } private static void saveToDatabase(Vector dataHolder) { for (int i=0;i&lt;dataHolder.size(); i++) { Vector cellStoreVector=(Vector)dataHolder.elementAt(i); for (int j=0; j &lt; cellStoreVector.size();j++) { System.out.println("show....."); HSSFCell myCell = (HSSFCell)cellStoreVector.elementAt(j); Please help me here....How to get the each column values ? } </code></pre>
 

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