This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread for details.
The moose likes JDBC and the fly likes Creating ImageIcon with byte[] from RS.getBytes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Creating ImageIcon with byte[] from RS.getBytes" Watch "Creating ImageIcon with byte[] from RS.getBytes" New topic
Author

Creating ImageIcon with byte[] from RS.getBytes

Joanna Pycha
Greenhorn

Joined: Jun 26, 2002
Posts: 1
I am trying to create an ImageIcon
using a byte[] that I got
from the result set using getBytes.
The DB I am using is Access 2000
and I store my image as OLE Object data type.
I use
byte[] tmpValue = rs.getBytes(columnInt);
ImageIcon tmpImage = new ImageIcon(tmpValue);
..then When i print the imageIcon height
I get -1 and when I print the
imageIcon.getImageLoadStatus();
it returns "4" -- equivalent to an error loading
Any suggestions???
Joanna
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

If you are trying to write both bits at he same time (ie read from db and convert into ImageIcon), do them one at a time first.
Probably read the byte stream and dump it to either standard out or a file. If you dump it to a file you should be able to load it in a viewer.
After you know this is working, debug the ImageIcon bit. I've had problems with ImageIcon before when trying to do two things at one with it.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Creating ImageIcon with byte[] from RS.getBytes
 
Similar Threads
mailto
Store byte[] array in MS Access - Help!
Using ImageFileOutputStream
getBytes()
Mouse shift event coding - to trigger a predetermined sequence of images to a GUI