diff --git a/src/main/java/org/mariadb/jdbc/internal/common/packet/PacketOutputStream.java b/src/main/java/org/mariadb/jdbc/internal/common/packet/PacketOutputStream.java index 8f82884..c02e474 100644 --- a/src/main/java/org/mariadb/jdbc/internal/common/packet/PacketOutputStream.java +++ b/src/main/java/org/mariadb/jdbc/internal/common/packet/PacketOutputStream.java @@ -10,12 +10,15 @@ private static final int MAX_PACKET_LENGTH = 0x00ffffff; private static final int SEQNO_OFFSET = 3; private static final int HEADER_LENGTH = 4; - private static final int MAX_SEQNO = 0xffff; - - + OutputStream baseStream; byte[] byteBuffer; int position; + + /** + * The server wants a value between 0 add 255. Only the least significant bits of this + * attribute is sent to the server + */ int seqNo; boolean compress; @@ -49,14 +52,14 @@ byteBuffer[0] = 0; byteBuffer[1] = 0; byteBuffer[2] = 0; - byteBuffer[SEQNO_OFFSET] = (byte)seqNo; + byteBuffer[SEQNO_OFFSET] = (byte)seqNo; //Send a value between 0 and 255 (seqNo may be cropped) baseStream.write(byteBuffer, 0, 4); position = HEADER_LENGTH; } /* Used by LOAD DATA INFILE. End of data is indicated by packet of length 0. */ public void sendFile(InputStream is, int seq) throws IOException{ - byte[] buffer = new byte[8192]; + byte[] buffer = new byte[65536]; //This may cause problems if max_allowed_packet is very low int len; while((len = is.read(buffer)) > 0) { startPacket(seq++); @@ -79,9 +82,6 @@ public void write(byte[] bytes, int off, int len) throws IOException{ if (seqNo == -1) { throw new AssertionError("Use PacketOutputStream.startPacket() before write()"); - } - if (seqNo == MAX_SEQNO) { - throw new IOException("MySQL protocol limit reached, you cannot send more than 4GB of data"); } for (;;) {