title: Insert Excel Data to database
body: <p>i suppose to insert the excel sheet data into database by a java program i am not getting the actual output.
      the excel sheet does not contain headings they given in the row 
      i need to get each row and make it as insert script.</p>
  
  <p>the data should be insert directly in database</p>
  
  <pre><code>  client                   page                AcessDate           ProcessTime  bytes
  12.34.56.9876545    hello.jsp           6/3/2014 5:52:16 PM 3        123
  12.34.56.9876545    SignOut.jsp         6/3/2014 6:21:16 PM 0   1724
  12.34.56.9876545    Login.jsp           6/3/2014 6:21:16 PM 0   4937
  </code></pre>
  
  <p>i shoud get the output as</p>
  
  <pre><code>insert into ClickStream(Client,Page,AccessDate,ProcessTime,Bytes)
  value('"+12.34.56.9876545   +"','"+hello.jsp+"','"+ 6/3/2014 5:52:16 PM+"','"+3+"','"+1724+"'"
  </code></pre>
  
  <p>i am useing the code i am not getting and see if my code working or not i cant able to get the right output </p>
  
  <pre><code>import java.io.FileInputStream;
  import java.sql.Connection;
  import java.sql.DriverManager;
  import java.sql.Statement;
  import java.util.Iterator;
  import java.util.Vector;
  
  import org.apache.poi.openxml4j.opc.OPCPackage;
  import org.apache.poi.poifs.filesystem.POIFSFileSystem;
  import org.apache.poi.xssf.usermodel.XSSFCell;
  import org.apache.poi.xssf.usermodel.XSSFRow;
  import org.apache.poi.xssf.usermodel.XSSFSheet;
  import org.apache.poi.xssf.usermodel.XSSFWorkbook;
  
    public class InsertExcelFileData {
    public static void main( String [] args ) {
      String fileName="F:\\book.xlsx";
      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);
          XSSFWorkbook myWorkBook = new XSSFWorkbook(myInput);
          XSSFSheet mySheet = myWorkBook.getSheetAt(0);
         Iterator rowIter = mySheet.rowIterator(); 
         while(rowIter.hasNext()){
                XSSFRow myRow = (XSSFRow) rowIter.next();
                Iterator cellIter = myRow.cellIterator();
                Vector cellStoreVector=new Vector();
                while(cellIter.hasNext()){
                        XSSFCell myCell = (XSSFCell) cellIter.next();
                        cellStoreVector.addElement(myCell);
                }
                cellVectorHolder.addElement(cellStoreVector);
        }
      }catch (Exception e){e.printStackTrace(); }
      return cellVectorHolder;
  }
      private static void saveToDatabase(Vector dataHolder) {
      String Client="";
              String Page="";
                String AccessDate="";
                String   ProcessTime="";
                String Bytes="";
              for (int i=0;i&lt;dataHolder.size(); i++){
                 Vector cellStoreVector=(Vector)dataHolder.elementAt(i);
                      for (int j=0; j &lt; cellStoreVector.size();j++){
                              XSSFCell myCell = (XSSFCell)cellStoreVector.elementAt(j);
                              String st = myCell.toString();
                              Client=st;
                              Page=st.substring(0);
                              System.out.print(st);
                                          }
                      try{
  Class.forName("com.jnetdirect.jsql.JSQLDriver").newInstance();
  Connection con = DriverManager.getConnection("jdbc:JSQLConnect://12.33.44.55/database=Environment", "root", "root");
      Statement stat=con.createStatement();
      int k=stat.executeUpdate("insert into ClickStream(Client,Page,AccessDate,ProcessTime,Bytes) value('"+Client+"','"+Page+"','"+AccessDate+"','"+ProcessTime+"','"+Bytes+"'");
      System.err.print(k);
  
      System.out.println("Data is inserted");
      stat.close();
      con.close();
      }
      catch(Exception e){}
      }
      }
    }
  </code></pre>
  
  <p>please help to get the code work properly</p>