I am working with mysql and dropwizard, I have a model with a field [Blob], I want store images there. But I create Blob with a array bytes and i do the insertion with a DAO. Note:In my database, the column Blob is empty. And I can't store my image.Help me!. Thank!
--
You received this message because you are subscribed to the Google Groups "jDBI" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jdbi+uns...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Hi Matthew Hall,
My code:
1. method:
public Either<IException,String > createAnnouncement(Integer id_Person, String createADTOString, InputStream imageByteArray) {
try {
byte[] image = convertImagetoByte(imageByteArray);
Blob blob=new SerialBlob(image);
long id_announcement = announcementDAO.createAnnouncementTest(createADTO.getStart(), createADTO.getEnd(), createADTO.getType(), image);
} catch (Exception e) {
return Either.left(ManagementException.catchException(e));
}
}2. JDBI@SqlUpdate("INSERT INTO announcement (start,end,type, image) VALUES(:start, :end,:type, :imageAux)")
@GetGeneratedKeys
long createAnnouncementTest(@Bind("start")Timestamp start, @Bind("end")Timestamp end,@Bind("type") String type, @Bind("imageAux") byte[] blob);--
I try to pass the image field as a byte or blob. But in my bd the image , the record is undefined
I tested the BLOB object as a parameter, and the Byte. but none work. For example:
@SqlUpdate("INSERT INTO announcement (start,end,type, image) VALUES(:start, :end,:type, :imageAux)")
@GetGeneratedKeys
long createAnnouncementTest(@Bind("start")Timestamp start, @Bind("end")Timestamp end, @Bind("type") String type, @Bind("imageAux") Blob blob);