Blob b=rs.getBlob(12);
bytes[] imagebytes=new bytes[(int)b.length()];
Image image;
image=getToolkit().createImage(imagebytes);
ImageIcon icon =new ImageIcon(image);
jLabel22.setIcon(icon);

This will not work. help me to display the image

Re: To display retrieved image from oracle database using java 80 80

Your second line creates a byte array of the right size, but you do not copy the data from the blob into that array, so the array is just full of zeros.
Use getBytes to convert the blob to a byte array (see the API dec for Blob for details).

Re: To display retrieved image from oracle database using java 80 80

and let's hope that the streaming of the image into the blob left it in a state where calling getBytes() on it would leave you with data that createImage() can interpret.

Re: To display retrieved image from oracle database using java 80 80

^ yes. Whatever encoding is used to convert the blob to an Image must be the inverse of whatever encoding was used to create the blob in the fist place.

You can also use blob.getBinaryStream() and use ImageIO to read from that if the blob was created by streaming as opposed to (eg) just getting the image's buffer.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.19 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.