Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » Reading BLOB image from MySQL database in spring mvc(how to read an image stored in mysql db in blob type to show(view) that image on the page)
Reading BLOB image from MySQL database in spring mvc [message #1487898] Wed, 26 November 2014 06:32 Go to next message
Mehbub Basha is currently offline Mehbub BashaFriend
Messages: 1
Registered: November 2014
Junior Member
I'm having some trouble reading a blob back from a MySQL database. I've gotten it to successfully insert into the database, but can't seem to get it to read back. I know some of you might be thinking "why is he using a database to store blobs for images, and not just the file paths / file names", but i want to have flexibility and as a lot of these images will be stored on a server and not locally, this optimises efficiency, as well as allowing me to move images to local if needed. I've followed a (short) tutorial and have written this following method for recieving a blob.

  • Attachment: image.txt
    (Size: 2.38KB, Downloaded 229 times)
Re: Reading BLOB image from MySQL database in spring mvc [message #1489229 is a reply to message #1487898] Thu, 27 November 2014 07:39 Go to previous message
Tomas Kraus is currently offline Tomas KrausFriend
Messages: 9
Registered: November 2014
Junior Member
I see that you are using java.sql.Blob for your @Lob attribute. I'm not sure that this would work properly. Check samples in @Lob annotation javadoc on Java EE 7 API page.
Recommended type is String or byte array depending on what kind of data you would like to store. Think in your case you can simply put your image into byte array atribute without any base64 encoding to save some space.

    @Column(name="CONTENT")
    @Lob
    private byte[] content;

Previous Topic:How can I obtain instance of Project class so I can call setDefaultQueryResultsCachePolicy?
Next Topic:Eclipselink - JPA 2.0 - Select with lockMode and maxResult doesn't work
Goto Forum:
  


Current Time: Tue Mar 19 05:33:27 GMT 2024

Powered by FUDForum. Page generated in 0.01514 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top