aspose file tools*
The moose likes JDBC and the fly likes URGENT: Accessing OLE object using java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "URGENT: Accessing OLE object using java" Watch "URGENT: Accessing OLE object using java" New topic
Author

URGENT: Accessing OLE object using java

Afroz Khan
Ranch Hand

Joined: Aug 07, 2000
Posts: 105
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


Afroz
Jamie Robertson
Ranch Hand

Joined: Jul 09, 2001
Posts: 1879

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
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
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
 
Don't get me started about those stupid light bulbs.
 
subject: URGENT: Accessing OLE object using java