• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Accessing image from ms-access

 
Ranch Hand
Posts: 105
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi
Here is my code for accessing the image from the access database, stored in OLE object field:
//----------
PreparedStatement stmt =con.prepareStatement("select picture from picturefile");
rs = stmt.executeQuery ();
int length=0;
int count=1;
while(rs.next())
{
InputStream is=rs.getBinaryStream(1);
String s="c:"+File.separator+"test"+File.separator+count+".gif";
FileOutputStream f=new FileOutputStream(s);
int c;
byte buffer[]=new byte[1024];
while((c=is.read(buffer)) != -1)
{
f.write(buffer, 0,c);
}
is.close();
f.close();
count=count+1;
}
rs.close();
con.close();
===========
The above code is generating files from the database and storing in hard disk, but when i open any file, its opening as blank.
Can anyone tell me how to access the images from the access db and store it in harddisk, and how to check for the image format whether its jpg or gif or bmp
Thanks
Afroz
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic