MySQL Forums
Forum List  »  Newbie

Re: Inserting a JPG into a BLOB syntax
Posted by: Alex Oleynikov
Date: April 29, 2009 04:14PM

May be anyone know if this is the problem. Using following syntax to instert a blob value column:

byte[] b = new byte[1200000];
PreparedStatement stmt = conn.prepareStatement("insert into t2 values (?,?)");
stmt.setObject(1, new Integer(1));
stmt.setBinaryStream(2, new ByteArrayInputStream(b), b.length);

It is failing with error: "Packet for query is too large (24000040 > 10485760)".

a. I'm sending over 12mb of bytes, why does it need 24Mb?
b. Why it is not chunking streaming of the blob. I understand that I can increase max_allowed_packet size on the server, but what if I need to stream 1Gb of binary data? According to MySql docs it is supposed to chunk Blobs which is controlled by following JDBC url property, but clealy it is not doing it.

blobSendChunkSize Chunk to use when sending BLOB/CLOBs via ServerPrepared-
Statements. Default value 1048576 (1M)

Options: ReplyQuote

Written By
Re: Inserting a JPG into a BLOB syntax
April 29, 2009 04:14PM

Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.