jpg file to blob in MySQL



I am reading a jpeg file into a byte []:

File flimage = new File("c:\temp.jpg");
byte[] b = new byte[(int)flimage.length()];
try{
InputStream isImage = new FileInputStream(flimage);
isImage.read(b);
}catch(Exception e){
e.printStackTrace();
return null;
}

It returns a valid byte[].

I then update my blobs table with this.

String qstring = "UPDATE blobs SET blb= ? WHERE
id="+Integer.toString(cs.idinblobs);

Looking at the db tables, all looks well. But, when I go to read the blob
back and create an ImageIcon from it:


ArrayList v2....//this is from the resultset of
the blobs table

byte[] jack = (byte[])v2.get(colinrow);
ii = new ImageIcon(jack);

if(ii.getImageLoadStatus() ==
MediaTracker.COMPLETE){
jEditTextField[e].setText(ii.getImage());
}else if(ii.getImageLoadStatus() ==
MediaTracker.ABORTED){
System.out.println("Image loading ABORTED");
jEditTextField[e].setText(null);
}else if(ii.getImageLoadStatus() ==
MediaTracker.ERRORED){
System.out.println("Image loading ERRORED");
jEditTextField[e].setText(null);
}else if(ii.getImageLoadStatus() ==
MediaTracker.LOADING){
System.out.println("Image loading LOADING");
}
}catch(Exception ignorefornow){
ignorefornow.printStackTrace();
}

which gives me the following exception:

sun.awt.image.ImageFormatException: Invalid JPEG file structure: two
SOF markers
at sun.awt.image.JPEGImageDecoder.readImage(Native Method)
at
sun.awt.image.JPEGImageDecoder.produceImage(JPEGImageDecoder.java:144)
at
sun.awt.image.InputStreamImageSource.doFetch(InputStreamImageSource.java:254)
at sun.awt.image.ImageFetcher.fetchloop(ImageFetcher.java:172)
at sun.awt.image.ImageFetcher.run(ImageFetcher.java:136)
Image loading ERRORED


Does anyone have any idea why this giving me this problem? I have not hat
trouble saving blobs before, but, for some reason, with these pictures, it
is failing me. Thanks, Ike



.