Java - XLSX parse & database export
<p>I have an excel that filled about 50k-60k rows.</p>
<p>I have to make that excel content uploaded into MySQL, usually I use the apache poi to read and upload it into MySQL, but this file cannot be read using apache poi cause the file was to LARGE.</p>
<p>Can anybody guide me how to do that? Here is my sample code to upload the content into MySQL using apache poi (it works for some little xlsx files that contains 1000-2000 rows)</p>
<pre><code>public static void uploadCrossSellCorpCard(FileItem file, String dbtable) {
    System.out.println(&quot;UploadUtil Running&quot; + file.getFileName().toString());
    try {
        for(int i = 0; i&lt;=sheetx.getLastRowNum(); i++){
            row = sheetx.getRow(i);
            
            try{
                int oc = (int) row.getCell(0).getNumericCellValue();
                if((String.valueOf(oc).matches(&quot;[A-Za-z0-9]{3}&quot;))){
                    String rm_name = row.getCell(1).getStringCellValue();
                    String company = row.getCell(2).getStringCellValue();
                    String product = row.getCell(3).getStringCellValue();
                    String detail = row.getCell(4).getStringCellValue();
                    String type = row.getCell(5).getStringCellValue();
                    
                    String sql = &quot;INSERT INTO &quot; + dbtable + &quot; VALUES('&quot;
                            + oc + &quot;','&quot; + rm_name + &quot;','&quot; + company + &quot;','&quot;
                            + product + &quot;','&quot; + detail + &quot;','&quot; + type + &quot;')&quot;;           
                    save(sql);
                    System.out.println(&quot;Import rows &quot; + i);
                }
            } catch (IllegalStateException e) {
                e.printStackTrace();
            } catch (NullPointerException e) {
                System.out.println(e);
            }
        }
        System.out.println(&quot;Success import xlsx to mysql table&quot;);
    } catch (NullPointerException e){
        System.out.println(e);
        System.out.println(&quot;Select the file first before uploading&quot;);
    }
}
</code></pre>
<p>Note: I use hibernate method for handle upload schema.. &quot;save(sql)&quot; is calling my hibernate method</p>