ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Clinton Begin <clinton.be...@gmail.com>
Subject Re: BLOB/LONGBLOB w/ MySQL & Connector/J
Date Mon, 10 Jan 2005 04:42:46 GMT
Yes, definitely specify the types as javaType="byte" and
jdbcType="BLOB".  Also be sure to use iBATIS 2.0.9, as it is the first
to have included BLOB/CLOB type handlers.  If that doesn't work (i.e.
if MySQL doesn't support standard JDBC BLOB API), then you may have to
write a custom type handler.

Cheers,
Clinton


On Sun, 09 Jan 2005 14:29:20 -0700, Nathan Maves <Nathan.Maves@sun.com> wrote:
> Are you using a result map?  If so send it out.  If you are not then
> you need to specify the type inline.
> 
> Nathan
> 
> 
> On Jan 9, 2005, at 12:27 PM, Brice Ruth wrote:
> 
> > I'm using the latest Connector/J driver (3.1.6) for MySQL 3.23.58
> > (don't ask - inherited database). Anyway, I've never much used BLOB
> > fields, but I need to pull some data out of this database.
> >
> > I went and grabbed 2.0.9 and saw that it had built-in support for
> > BLOB/CLOB as long as your driver (and database?) were well-behaved.
> >
> > Of course, the docs haven't quite caught up with the release, so I'm
> > not sure what qualifies as a well-behaved driver.
> >
> > I did try a simple test to see if I could just get lucky ... ;)
> >
> > My JavaBean simply defines three fields as byte[]. The select in my
> > SqlMap looks like this:
> >
> >       <select id="getImages" resultClass="Image">
> >               SELECT
> >                       ean,
> >                       picorg AS original,
> >                       picthumb AS thumb,
> >                       picscale AS scale
> >               FROM
> >                       bb_data a
> >               LEFT OUTER JOIN
> >                       bb_pic b
> >               ON
> >                       a.id=b.id
> >               ORDER BY
> >                       ean
> >               LIMIT 1
> >       </select>
> >
> > Where "Image" is an alias defined in my config. No errors are thrown
> > by iBATIS - but when I try to do something like getThumb().length - I
> > get an NPE. The fields picthumb and picscale are BLOBs, picorg is a
> > LONGBLOB. The other field, ean, is just a string - which is pulled out
> > correctly.
> >
> > Any guidance? Been a long time iBATIS user, just not with BLOB fields
> > :)
> >
> > Thanks!
> >
> > Brice
> 
>

Mime
View raw message