--- ./src/main/java/org/mariadb/jdbc/internal/protocol/AbstractQueryProtocol.java.orig 2017-09-20 20:54:14.294927700 +0200 +++ ./src/main/java/org/mariadb/jdbc/internal/protocol/AbstractQueryProtocol.java 2017-09-20 20:56:47.478818400 +0200 @@ -1486,9 +1486,14 @@ } try { + byte[] buff = new byte[1024 * 1024]; + int read = 0; + while ((read = is.read(buff)) != -1) { writer.startPacket(seq); - writer.write(is, false, false); + writer.write(buff, 0, read); writer.flush(); + seq ++; + } writer.writeEmptyPacket(); } catch (MaxAllowedPacketException ioe) { //particular case : error has been throw before sending packets.