-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 
Author Message
 Post subject: Problem with insert
PostPosted: Mon May 07, 2007 9:16 am 
Newbie

Joined: Mon Apr 09, 2007 10:29 am
Posts: 14
Hi
I am saving images as binary file. Its about 4 MB in size.
I am using MySql as Database and the LongBlob as field.
When i use session.Save it throws an Exception
"MySql.Data.MySqlClient.MySqlException] {"Packets larger than max_allowed_packet are not allowed."}"
but the dimnesion of ByteArray is [4427572] and if the contents stored in the text file the size is only 1 MB
Everything works fine if the size is small.

<component name="Description" class="BusinessObjects.TestModule.DescriptionClass, BusinessObjects.TestModule">
<property name ="RtfByte" column ="Rtf_Description" type="BinaryBlob" not-null="true"/>
<property name="MhtmlByte" column="Mhtml_Description" type="BinaryBlob" not-null="true"/>
</component>

this is the code Rtf and Mhtml are the strings the i need in order to save to the database i am using Byte[] (though mapping them as StringClob in hbm also works and no need to convert i dont know which one is better any help in that??)
public string Rtf
{
get { return _rtf; }
set { _rtf = value; }
}

public string Mhtml
{
get { return _mhtml; }
set { _mhtml = value; }
}

private Byte[] RtfByte
{
get { return Encoding.UTF32.GetBytes(_rtf); }
set { _rtf = Encoding.UTF32.GetString(value); }
}

private Byte[] MhtmlByte
{
get { return Encoding.UTF8.GetBytes(_mhtml); }
set { _mhtml = Encoding.UTF8.GetString(value); }
}

Why is this error coming as i am saving directly to Db it works

Thanx
Saurabh


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 07, 2007 9:28 am 
Newbie

Joined: Mon Apr 09, 2007 10:29 am
Posts: 14
I can change the maximum allowed packet size to tackle this problem. But is there another and a better solution that this

TIA


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 07, 2007 9:48 am 
Newbie

Joined: Mon Apr 09, 2007 10:29 am
Posts: 14
I have increased the Packets Max Size to 8MB still the error continues?
:((


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 09, 2007 5:13 am 
Newbie

Joined: Mon Mar 26, 2007 7:50 am
Posts: 18
try to set the max_allowed_packet in your my.ini

but you have to set it for the client as well as for the server

e.g.

[mysql]
max_allowed_packet=32M;

[mysqld]
max_allowed_packet=32M;

regards omid


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.