Does s.execute("Create table Img(Image_No number(5),Photo blob)"); run successfully? I ask because you catch the exception but then continue on. If that doesn't run, all bets are off for what happens later in the program.
The actual error is about a type conversion error. I don;t usually pass the length as a second parameter to setBinaryStream. You might try without that.
thank you Jeanne Boyarsky . ya i am using oracle 10g database and the table is created in the database , what you said is right. problem is with typecasting so, i tried ps.setBinaryStream(2,fis,(byte)file.length());
rather than
ps.setBinaryStream(2,fis,(int)file.length());
so, it worked properly. is it correct? can i approach in this way??
Jeanne Boyarsky wrote:Also, what database are you using? Different databases support Blobs in different ways. (or not at all)
The posted code uses the JDBC-ODBC bridge driver. I wouldn't be at all surprised to find out that it doesn't support blobs, even if the underlying database does.
Well a bit off track answer from my side sorry for this... but i would rather suggest you to store the image path in the database instead of image itself.
So that either it is a web application or desktop application you only need to provide the path for the image to display. It may be Label component for desktop or img tag of the web-page.
The only thing you require to do is to save image file in some specific folder and store its path in the database and then retrieve it later to display.
Thankyou.
| B.E IT | SCJP 6.0 98 % |
You get good luck from rubbing the belly of a tiny ad:
Gift giving made easy with the permaculture playing cards