Db4o ObjectContainer factory


/ Published in: Java
Save to your folder(s)

Factory for ObjectContainer for local db4o database


Copy this code and paste it in your HTML
  1. import java.io.File;
  2.  
  3. import com.db4o.ObjectContainer;
  4. import com.db4o.ObjectServer;
  5. import com.db4o.cs.Db4oClientServer;
  6. import com.db4o.cs.config.ServerConfiguration;
  7.  
  8. public abstract class Db4oConnManager {
  9.  
  10. private static final String DB4O_DB_FILE = "/home/dogrizz/db4o.db";
  11.  
  12. private final static ObjectServer db;
  13. static {
  14. ServerConfiguration conf = Db4oClientServer.newServerConfiguration();
  15. db = Db4oClientServer.openServer(conf, DB4O_DB_FILE, 0);
  16.  
  17. }
  18.  
  19. public static ObjectContainer getManager() {
  20.  
  21. return db.openClient();
  22. }
  23.  
  24. public static void clear() {
  25. db.close();
  26. new File(DB4O_DB_FILE).delete();
  27. }
  28.  
  29. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.