How to transfer excel sheet data to mysql using Java POI
<p>I am attempting to transfer my excel sheet data which have merged columns to mysql database. I can import normal excel file data but merged rows are creating problems.</p>

<pre><code>package exp;

import java.io.FileInputStream;
import java.io.IOException;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
</code></pre>

<p>//  import org.apache.poi.ss.usermodel.Row;
     import org.apache.poi.ss.usermodel.*;</p>

<pre><code> public class TestApp {

public static void main(String[] args) throws Exception {

    try {

        Class forName = Class.forName("com.mysql.jdbc.Driver");
        Connection con = null;
        con = DriverManager.getConnection("jdbc:mysql://localhost", "root",     "anubhavkumar");
        con.setAutoCommit(false);
        PreparedStatement pstm = null;
        PreparedStatement pstn = null;
        FileInputStream input = new     FileInputStream("C:\\Users\\AK00459604\\Desktop\\Worksheet141.xls");
        POIFSFileSystem fs = new POIFSFileSystem(input);
        Workbook workbook;
        workbook = WorkbookFactory.create(fs);
        Sheet sheet = workbook.getSheetAt(0);
        Row row;
        for (int i = 1; i &lt;= sheet.getLastRowNum(); i++) {
            row = (Row) sheet.getRow(i);

            String User_Registration = row.getCell(0).getStringCellValue();
            String Approval_On_TestEnvironment = row.getCell(1).getStringCellValue();


            String sql1 = "USE db1";
            pstn = (PreparedStatement) con.prepareStatement(sql1);
            pstn.execute();

            String sql = "INSERT INTO WORKSHEET1412 ( User_Registration,Approval_On_TestEnvironment) VALUES('" + User_Registration + "','" + Approval_On_TestEnvironment + "')";
            pstm = (PreparedStatement) con.prepareStatement(sql);
            pstm.execute();
            System.out.println("Import rows " + i);
        }
        con.commit();
        pstm.close();
        con.close();
        input.close();
        System.out.println("Success import excel to mysql table");
    } catch (IOException e) {
    }
}
</code></pre>

<p>}</p>