Win a copy of Learning Java by Building Android Games this week in the Android forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • Devaka Cooray
Saloon Keepers:
  • Ganesh Patekar
  • Tim Moores
  • Carey Brown
  • Stephan van Hulst
  • salvin francis
Bartenders:
  • Ron McLeod
  • Frits Walraven
  • Pete Letkeman

URGENT: Accessing OLE object using java  RSS feed

 
Ranch Hand
Posts: 105
  • 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
 
Ranch Hand
Posts: 1879
MySQL Database Suse
  • 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
  • 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
  • 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
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!