title: Read 100 GB .csv file from java and insert into MS SQL server DB
body: <p><br>
  I am trying to read data from csv file and insert into DB, using batch insertion. But it’s throwing multiple exceptions.<br> </p>
  
  <pre><code>java.sql.BatchUpdateException: A statement attempted to return a result set in executeBatch().&lt;br&gt;
  SEVERE: Servlet.service() for servlet oms threw exception
  java.lang.OutOfMemoryError: Java heap space ……. &lt;br&gt;
  </code></pre>
  
  <p>Inserting code is bellow given :-<br></p>
  
  <pre><code> public long updateOpenOrdData(Connection conn, String[] paramStrObj)throws Exception {
              long updatedRow = 0;
              CallableStatement cstmt = null;
               // System.out.println("StrAtt length :"+ strArr.length);
              try{
                  for(int i=0; i&lt;paramStrObj.length; i++){
                      int count =1;
                      int index = 0;
                      String[] dataArr = paramStrObj[i].split(",(?=([^\"]*\"[^\"]*\")*[^\"]*$)", -1); 
                      if(!dataArr[0].equals("SLC_Code_Desc") &amp;&amp; dataArr.length &gt;= 24 ){
                          cstmt = conn.prepareCall(PROC_INSERT_OPEN_ORD_TEMP);
                          System.out.print(dataArr[index]+", ");
                          cstmt.setString(count++, dataArr[index++]);
                          System.out.print(dataArr[index]+", ");
                          cstmt.setString(count++, dataArr[index++]);
                          cstmt.setString(count++, dataArr[index++]);
                          cstmt.setString(count++, dataArr[index++]);
                          cstmt.setString(count++, dataArr[index++]);
                          cstmt.setString(count++, dataArr[index++]);
                          cstmt.setString(count++, dataArr[index++]);
                          cstmt.setString(count++, dataArr[index++]);
                          cstmt.setString(count++, dataArr[index++]);
                          cstmt.setString(count++, dataArr[index++]);
                          cstmt.setString(count++, dataArr[index++]);
                          cstmt.setString(count++, dataArr[index++]);
                          cstmt.setString(count++, dataArr[index++]);
                          cstmt.setString(count++, dataArr[index++]);
                          cstmt.setString(count++, dataArr[index++]);
                          cstmt.setString(count++, dataArr[index++]);
                          cstmt.setString(count++, dataArr[index++]);
                          cstmt.setString(count++, dataArr[index++]);
                          cstmt.setString(count++, dataArr[index++]);
                          cstmt.setString(count++, dataArr[index++]);
                          cstmt.setString(count++, dataArr[index++]);
                          cstmt.setString(count++, dataArr[index++]);
                          cstmt.setString(count++, dataArr[index++]);
                          cstmt.setString(count++, dataArr[index]);
                          cstmt.setString(count++, null);
                          cstmt.setString(count++, null);
                          cstmt.setString(count++, null);
                          cstmt.addBatch();
                          //cstmt.executeUpdate();
                          }
                      }
                  int[] insertRow =cstmt.executeBatch();
                  System.out.println("Inserted row are :: "+insertRow);
                  }catch (Exception e) {
                  //System.out.println("Wrong data at line "+i+" and column "+ --index);
                  e.printStackTrace();
              }finally{
                  new DBService().releaseResources(null, cstmt);
              }
  
              return updatedRow;
          }
  </code></pre>
  
  <p>I need to insert data up to 100 GB.
  In this code one row is inserting every time.</p>