Saving binary data to a blobfiled

Forum related to MySQL

Moderators: gto, cipto_kh, EgonHugeist

Post Reply
pal1952
Fresh Boarder
Fresh Boarder
Posts: 2
Joined: 24.08.2014, 08:06

Saving binary data to a blobfiled

Post by pal1952 »

Zeoslib 7.1.3 Stable, Delphi XE4, Windows 7

I am trying to save binary data (exe files) into a blob field (longblob) using the following code:

When I execute it I get "MySql server has gone away". It does work on smaller files < 1MB.

Any ideas.


try
Import := TZTable.Create(nil);
Import.Connection := Connection;
Import.TableName := 'Versions';
Import.Open;

Import.Insert;
Import.FieldByName('FileName').AsString := ExtractFileName(FileName);
Import.FieldByName('VersionNo').AsInteger := ExistingVersion.AsInteger;
Import.FieldByName('CRC').AsInteger := CRC;

try
FileStream := TFileStream.Create(FileName, fmOpenRead);
TBlobField(Import.FieldByName('Exe')).LoadFromStream(FileStream);

finally
FileStream.Free;
end;

Import.Post;

Import.Close;
finally
Import.Free;
end;
User avatar
EgonHugeist
Zeos Project Manager
Zeos Project Manager
Posts: 1936
Joined: 31.03.2011, 22:38

Re: Saving binary data to a blobfiled

Post by EgonHugeist »

Hi,

AFAIR is this related to server-settings. Execute 'SET GLOBAL max_allowed_packet=16*1024*1024;'
And another suggestion:

Add 'preferprepared=True' to the TZDataSet.Properties. This parameter enables the MySQL real-prepared stmt and this can send lob's in chunks.
Best regards, Michael

You want to help? http://zeoslib.sourceforge.net/viewtopic.php?f=4&t=3671
You found a (possible) bug? Use the new bugtracker dude! http://sourceforge.net/p/zeoslib/tickets/

Image
pal1952
Fresh Boarder
Fresh Boarder
Posts: 2
Joined: 24.08.2014, 08:06

Re: Saving binary data to a blobfiled

Post by pal1952 »

Hi

Thanks you for the "set global" comment, it fixes the problem perfectly; I have changed the server ini now. I had wondered if it was a setting, I should have thought before I posted.

I will try the "prefer prepared" line.

Thanks for the help.

Peter
Post Reply