You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-java@ibatis.apache.org by Mark P Ashworth <in...@connext.co.za> on 2007/07/01 09:13:00 UTC
MySQL and Blob
Good Day,
I am trying to insert a byte[] field into a MySQL database.
<resultMap id="EmailResult" class="Email">
<result property="id" column="email_id"/>
<result property="name" column="name"/>
<result property="subject" column="subject"/>
<result property="from" column="from"/>
<result property="body" column="body" jdbcType="BLOB" javaType="[B"/>
<result property="type" column="type" />
</resultMap>
<insert id="insertEmail" parameterClass="Email">
insert into email (
name,
subject,
from,
body,
type
) values (
#name#,
#subject#,
#from#,
#body#,
#type#
)
</insert>
When I look at the SQL generated I see that it has not converted the body
field correctly so that MySQL will accept the statement.
insert into email ( name, subject, from, body,
type ) values ( 'register', 'Test',
'info@connext.co.za', '[B@11381e7', '' )
I am using iBatis 2.3.0.677
Regards,
Mark P Ashworth
--
View this message in context: http://www.nabble.com/MySQL-and-Blob-tf4007004.html#a11379634
Sent from the iBATIS - User - Java mailing list archive at Nabble.com.
Re: MySQL and Blob
Posted by Mark P Ashworth <in...@connext.co.za>.
Good Day,
I remember that Oracle had or has the same usage pattern when it comes to
BLOB and CLOB. I will give it a go.
Regards,
Mark P Ashworth
http://www.connext.co.za
wowiesy wrote:
>
> I'm using Spring / iBATIS and I couldn't make inserting a BLOB work. The
> workaround I did (which worked, but I still don't know why) is that I
> first inserted the data not including the BLOB column (the BLOB column has
> null as default value), and then I just issue an update on the BLOB
> column).
>
> Regards,
> wowiesy
>
>
>
>
>
> Mark P Ashworth wrote:
>>
>> Good Day,
>>
>> At first I did not have the jdbcType or javaType and then systematically
>> added them because I was getting the same error the whole time.
>>
>> I used the php admin interface to add file data in the blob data field,
>> and when I retrieve the data is present, I am just not sure how to get
>> the insert to work.
>>
>> Regards,
>> Mark P Ashworth
>>
>>
>>
>> Larry Meadors-2 wrote:
>>>
>>> Did you try it w/o the jdbcType and javaType?
>>>
>>> Larry
>>>
>>>
>>> On 7/1/07, Mark P Ashworth <in...@connext.co.za> wrote:
>>>>
>>>> Good Day,
>>>>
>>>> I am trying to insert a byte[] field into a MySQL database.
>>>>
>>>> <resultMap id="EmailResult" class="Email">
>>>> <result property="id" column="email_id"/>
>>>> <result property="name" column="name"/>
>>>> <result property="subject" column="subject"/>
>>>> <result property="from" column="from"/>
>>>> <result property="body" column="body" jdbcType="BLOB"
>>>> javaType="[B"/>
>>>> <result property="type" column="type" />
>>>> </resultMap>
>>>>
>>>> <insert id="insertEmail" parameterClass="Email">
>>>> insert into email (
>>>> name,
>>>> subject,
>>>> from,
>>>> body,
>>>> type
>>>> ) values (
>>>> #name#,
>>>> #subject#,
>>>> #from#,
>>>> #body#,
>>>> #type#
>>>> )
>>>> </insert>
>>>>
>>>> When I look at the SQL generated I see that it has not converted the
>>>> body
>>>> field correctly so that MySQL will accept the statement.
>>>>
>>>> insert into email ( name, subject, from, body,
>>>> type ) values ( 'register', 'Test',
>>>> 'info@connext.co.za', '[B@11381e7', '' )
>>>>
>>>> I am using iBatis 2.3.0.677
>>>>
>>>> Regards,
>>>> Mark P Ashworth
>>>> --
>>>> View this message in context:
>>>> http://www.nabble.com/MySQL-and-Blob-tf4007004.html#a11379634
>>>> Sent from the iBATIS - User - Java mailing list archive at Nabble.com.
>>>>
>>>>
>>>
>>>
>>
>>
>
>
--
View this message in context: http://www.nabble.com/MySQL-and-Blob-tf4007004.html#a11540153
Sent from the iBATIS - User - Java mailing list archive at Nabble.com.
Re: MySQL and Blob
Posted by wowiesy <ks...@i-manila.com.ph>.
I'm using Spring / iBATIS and I couldn't make inserting a BLOB work. The
workaround I did (which worked, but I still don't know why) is that I first
inserted the data not including the BLOB column (the BLOB column has null as
default value), and then I just issue an update on the BLOB column).
Regards,
wowiesy
Mark P Ashworth wrote:
>
> Good Day,
>
> At first I did not have the jdbcType or javaType and then systematically
> added them because I was getting the same error the whole time.
>
> I used the php admin interface to add file data in the blob data field,
> and when I retrieve the data is present, I am just not sure how to get the
> insert to work.
>
> Regards,
> Mark P Ashworth
>
>
>
> Larry Meadors-2 wrote:
>>
>> Did you try it w/o the jdbcType and javaType?
>>
>> Larry
>>
>>
>> On 7/1/07, Mark P Ashworth <in...@connext.co.za> wrote:
>>>
>>> Good Day,
>>>
>>> I am trying to insert a byte[] field into a MySQL database.
>>>
>>> <resultMap id="EmailResult" class="Email">
>>> <result property="id" column="email_id"/>
>>> <result property="name" column="name"/>
>>> <result property="subject" column="subject"/>
>>> <result property="from" column="from"/>
>>> <result property="body" column="body" jdbcType="BLOB"
>>> javaType="[B"/>
>>> <result property="type" column="type" />
>>> </resultMap>
>>>
>>> <insert id="insertEmail" parameterClass="Email">
>>> insert into email (
>>> name,
>>> subject,
>>> from,
>>> body,
>>> type
>>> ) values (
>>> #name#,
>>> #subject#,
>>> #from#,
>>> #body#,
>>> #type#
>>> )
>>> </insert>
>>>
>>> When I look at the SQL generated I see that it has not converted the
>>> body
>>> field correctly so that MySQL will accept the statement.
>>>
>>> insert into email ( name, subject, from, body,
>>> type ) values ( 'register', 'Test',
>>> 'info@connext.co.za', '[B@11381e7', '' )
>>>
>>> I am using iBatis 2.3.0.677
>>>
>>> Regards,
>>> Mark P Ashworth
>>> --
>>> View this message in context:
>>> http://www.nabble.com/MySQL-and-Blob-tf4007004.html#a11379634
>>> Sent from the iBATIS - User - Java mailing list archive at Nabble.com.
>>>
>>>
>>
>>
>
>
--
View this message in context: http://www.nabble.com/MySQL-and-Blob-tf4007004.html#a11539704
Sent from the iBATIS - User - Java mailing list archive at Nabble.com.
Re: MySQL and Blob
Posted by Mark P Ashworth <in...@connext.co.za>.
Good Day,
At first I did not have the jdbcType or javaType and then systematically
added them because I was getting the same error the whole time.
I used the php admin interface to add file data in the blob data field, and
when I retrieve the data is present, I am just not sure how to get the
insert to work.
Regards,
Mark P Ashworth
Larry Meadors-2 wrote:
>
> Did you try it w/o the jdbcType and javaType?
>
> Larry
>
>
> On 7/1/07, Mark P Ashworth <in...@connext.co.za> wrote:
>>
>> Good Day,
>>
>> I am trying to insert a byte[] field into a MySQL database.
>>
>> <resultMap id="EmailResult" class="Email">
>> <result property="id" column="email_id"/>
>> <result property="name" column="name"/>
>> <result property="subject" column="subject"/>
>> <result property="from" column="from"/>
>> <result property="body" column="body" jdbcType="BLOB" javaType="[B"/>
>> <result property="type" column="type" />
>> </resultMap>
>>
>> <insert id="insertEmail" parameterClass="Email">
>> insert into email (
>> name,
>> subject,
>> from,
>> body,
>> type
>> ) values (
>> #name#,
>> #subject#,
>> #from#,
>> #body#,
>> #type#
>> )
>> </insert>
>>
>> When I look at the SQL generated I see that it has not converted the
>> body
>> field correctly so that MySQL will accept the statement.
>>
>> insert into email ( name, subject, from, body,
>> type ) values ( 'register', 'Test',
>> 'info@connext.co.za', '[B@11381e7', '' )
>>
>> I am using iBatis 2.3.0.677
>>
>> Regards,
>> Mark P Ashworth
>> --
>> View this message in context:
>> http://www.nabble.com/MySQL-and-Blob-tf4007004.html#a11379634
>> Sent from the iBATIS - User - Java mailing list archive at Nabble.com.
>>
>>
>
>
--
View this message in context: http://www.nabble.com/MySQL-and-Blob-tf4007004.html#a11383532
Sent from the iBATIS - User - Java mailing list archive at Nabble.com.
Re: MySQL and Blob
Posted by Larry Meadors <lm...@apache.org>.
Did you try it w/o the jdbcType and javaType?
Larry
On 7/1/07, Mark P Ashworth <in...@connext.co.za> wrote:
>
> Good Day,
>
> I am trying to insert a byte[] field into a MySQL database.
>
> <resultMap id="EmailResult" class="Email">
> <result property="id" column="email_id"/>
> <result property="name" column="name"/>
> <result property="subject" column="subject"/>
> <result property="from" column="from"/>
> <result property="body" column="body" jdbcType="BLOB" javaType="[B"/>
> <result property="type" column="type" />
> </resultMap>
>
> <insert id="insertEmail" parameterClass="Email">
> insert into email (
> name,
> subject,
> from,
> body,
> type
> ) values (
> #name#,
> #subject#,
> #from#,
> #body#,
> #type#
> )
> </insert>
>
> When I look at the SQL generated I see that it has not converted the body
> field correctly so that MySQL will accept the statement.
>
> insert into email ( name, subject, from, body,
> type ) values ( 'register', 'Test',
> 'info@connext.co.za', '[B@11381e7', '' )
>
> I am using iBatis 2.3.0.677
>
> Regards,
> Mark P Ashworth
> --
> View this message in context: http://www.nabble.com/MySQL-and-Blob-tf4007004.html#a11379634
> Sent from the iBATIS - User - Java mailing list archive at Nabble.com.
>
>