Hi I m working on one application, where in I have to read the table from the access database. Can anyone tell me how to read the "Ole-object" field from the table. This field contains some images and i need to read the images and store in some database. But how do i read it? Thanks
Originally posted by Afroz Khan: Hi I m working on one application, where in I have to read the table from the access database. Can anyone tell me how to read the "Ole-object" field from the table. This field contains some images and i need to read the images and store in some database. But how do i read it? Thanks
usually you would use the ResultSet.getBinaryStream(int columnNumber) method, then retrieve the image using the returned InputStream as an input to your InputStreamReader, and read in the file using the InputStreamReader.
Afroz Khan
Ranch Hand
Joined: Aug 07, 2000
Posts: 105
posted
0
Hi Jamie Thanks for ur quick reply, Can u give me a sample code or just the method example. Thanks
Afroz Khan
Ranch Hand
Joined: Aug 07, 2000
Posts: 105
posted
0
Hi Jamie I have done something like this: while(rs.next()) { System.out.println("inside rs"); InputStream is=rs.getBinaryStream(1); String s="c:"+File.separator+count+".jpg"; FileOutputStream f=new FileOutputStream(s); int c; while ((c = is.read ()) != -1) f.write (c); f.close(); count=count+1; } ========= It is creating the image files but when i open the file its coming blank. I have changed the extension and tried. none of the extension is working. In .bmp its saying unrecognized format when i try to open the file. Is there any way to find out the file type stored in database? or u can help me in some other way. Thanks