Skip to content
Advertisement

unable to retrieve image from mysql through rest api using java

My problem is deceptively simple but I am unable to find the answer. Through Java and JDBI, I am able to retrieve the image from MySQL database and store it locally. But when I try with a rest api, it is giving the error in the attached screenshot. I have searched for this quite a bit but am unable to find a solution.

The stack trace is as below:

JavaScript

Adding the rest api and the listAllBooks method below :

JavaScript

The DAO and Factory methods return a Blob and I have a mapper for getting the blob from the DB.

Please guide as to how to solve this.

Advertisement

Answer

I finally found the solution to my issue. I added the below code to the dbi object.

JavaScript

I followed the this link for the solution.

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement