Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

URGENT: Accessing OLE object using java

 
Afroz Khan
Ranch Hand
Posts: 105
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Jamie Robertson
Ranch Hand
Posts: 1879
MySQL Database Suse
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 105
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Jamie
Thanks for ur quick reply, Can u give me a sample code or just the method example.
Thanks
 
Afroz Khan
Ranch Hand
Posts: 105
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic