Jump to content
Changes to the Jaspersoft community edition download ×

Jasper Report with Derby with java.sql.Blob as Image


Recommended Posts


I'm trying to test Jasper report with Derby database with image saved as java.sql.Blob.

I tried many times with different approches to load the image from the database (using expression) like,

//Getting java.awt.Image

new javax.swing.ImageIcon($F{A_SIGN_IC1}.getBytes(1, (int)$F{A_SIGN_IC1}.length())).getImage()

//Getting InputStream


Each time getting error.

Then tried to check the size of the Blob object by using $F{A_SIGN_IC1}.length(), it results 3.


Though, I tried to render image by writing separate Java program, it is working with below code.

        Connection con = DriverManager.getConnection("jdbc:derby://localhost:1527/sample", "user", "app");

        JFrame jf1 = new JFrame("Test");
        jf1.setSize(400, 400);
        JButton jb = new JButton("");
        jb.setSize(200, 300);
        PreparedStatement ps2 = con.prepareStatement("***");
        ResultSet rs = ps2.executeQuery();
        int z = 0;
        while(rs.next()) {
            Blob bl1 = rs.getBlob(1);
            ImageIcon ii = new ImageIcon(bl1.getBytes(1, (int)bl1.length()));
            java.awt.Image img = ii.getImage();


I'm not sure about the issue what is happening. Because if image is being rendered using separate Java program from the database that simply means image is stored correctly. It seems there is an issue with Jasper Only.


Please help.







Link to comment
Share on other sites

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Popular Days

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...