Saving binary data to a blobfiled

Forum related to MySQL

Moderators: gto, cipto_kh, EgonHugeist

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

Saving binary data to a blobfiled

Postby pal1952 » 24.08.2014, 08:27

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 Dev Team
Zeos Dev Team
Posts: 1748
Joined: 31.03.2011, 22:38

Re: Saving binary data to a blobfiled

Postby EgonHugeist » 24.08.2014, 13:45

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.
King regards, Michael

You want to help? 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

Postby pal1952 » 25.08.2014, 06:47

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


Return to “MySQL”

Who is online

Users browsing this forum: No registered users and 1 guest