code: public static int sendBatchAggregateSemiColon(final PacketOutputStream writer, String firstQuery,
        List<String> queries, int currentIndex) throws IOException {
      writer.startPacket(0);
      writer.write(Packet.COM_QUERY);
      //index is already set to 1 for first one
      writer.write(firstQuery.getBytes("UTF-8"));
  
      int index = currentIndex;
  
      //add query with ";"
      while (index < queries.size()) {
        byte[] sqlByte = queries.get(index).getBytes("UTF-8");
        if (!writer.checkRemainingSize(sqlByte.length + 1)) {
          break;
        }
        writer.write(';');
        writer.write(sqlByte);
        index++;
      }
  
      writer.flush();
      return index;
    }
docs: Statement.executeBatch() rewritten multiple (concatenate with ";") according to
  max_allowed_packet)
  
  @param writer       outputstream
  @param firstQuery   first query
  @param queries      queries
  @param currentIndex currentIndex
  @return current index
  @throws IOException if connection error occur