2

I have a desktop application with Java 7, where user can fill form with data and choose a picture (only .jpg format) with file chooser and that insert it to MS Access database (.accdb). The app admin can export all data inserted last month in .csv file and the pictures should be stored in folder as .jpg files.

I make a connection to MS Access database and successfully read and write data, but without the picture, so the question is:
- how to store a picture from file system in MS Access as OLE Object
- how to export a picture from OLE Object column to file system (as .jpg file)

Dragan Menoski
  • 1,022
  • 13
  • 30
  • If you able to use [Jackess](http://jackcess.sourceforge.net/jackcess-2.html) you can try the following [OleBlobTest.java](https://github.com/jahlborn/jackcess/blob/master/src/test/java/com/healthmarketscience/jackcess/util/OleBlobTest.java) – Victor Gubin Oct 17 '18 at 22:59

1 Answers1

1

There is a quite a bit of difference between using OLE in java and getting an OLE object from an MS Access database via Java.

Normally MS Access is accessed via the appropriate ODBC driver (which has nothing to do with java.) And ODBC does not support OLE objects directly. At least not as far as I recall nor that I can find.

So what one must do is exactly the OLE in binary and then exact information from that by manipulating it. In other words, the binary extracted contains an image and OTHER information. That other information is removed before the binary data will be an actual image.

Following provides some information.

Extract OLE Object from Access DB

BEFORE attempting to manipulate the image you MUST test the following. 1. Write your code to extract the image from the object. 2. Write the binary data to a file. 3. Use an appropriate external application to load the file and ensure the format is correct. 4. Repeat the above steps for all known variations Displaying an OLE Object