1

I want to store images in Db4o using Blobs. How can I store them and how do I get them out again?

1 Answer 1

3

Take a look at this question answer: How to stores and Pictures in Db40?

I repost my answer again, a bit updated with the links to the Java documentation:

There are two basic ways to handle Blobs. Either you store a blob as byte-array in the database or you use the special db4o-Blob-Type. Both have their advantages.

Advantages/Disadvantages with byte array:

  • The blobs are in the db4o-database-file. So there's only a single file to copy around.
  • Byte-arrays are part of the normal db4o-transaction and behave as expected.
  • When storing large blobs, you might run into the database-size limitation of db4o. (256 GB)

Advantages/Disadvantaged with db4o-blobs

  • The blobs are stored as regular files outside the database. This keeps the database itself small. Furthermore you just can access all stored blobs with a regular application.
  • You always need to copy the blob-directory and the database.
  • The db4o-blobs works outside the db4o transaction. This means that a db4o-blob behaves different than any other stored object (and the API is a little strange). However this allows to retrieve a db4o-blob without blocking the current transaction.

For your case I would store a byte[] array with the picture in the Person class. Or you create a special Image-class. This image-class contains then a byte-array with the picture. And a few methods to convert this byte-array from and to a Winforms-bitmap.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.