How to insert images from database?

Solution 1:

Open the XML view of .jrxml file. Then find code similar to this

<field name="image" class="java.lang.Object"/>  
/* "image" must be replaced by your actual field name */

and change it to

<field name="image" class="java.io.InputStream"/>

Solution 2:

It seems that I solved the issue myself.

Here are the steps I`v done:

1) The expression for the Image report field should be: $F{imgdata}

(Note: imgdata is name of the database field where image data is stored)

2) Open the "Dataset and Query Dialog" of your report and change the Class Type of the imgdata field from java.lang.Object to java.io.InputStream (see the screenshot --- sorry I dont have enough reputation points to post images). Close the dialog.

3) Generate your report by switching to Preview-Tab. Now you should see the images in your report.