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.
Also, what database are you using? Different databases support Blobs in different ways. (or not at all)
Joined: Aug 11, 2011
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());
so, it worked properly. is it correct? can i approach in this way??
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.
| B.E IT | SCJP 6.0 98 % |
subject: unimplemented or unreasonable request at ps.execute()