DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

Save Data With Db4o

09.17.2006
| 3768 views |
  • submit to reddit
        // save Data with db4o

import com.db4o.Db4o;
import com.db4o.ObjectContainer;
import com.db4o.ObjectSet;
import com.db4o.query.Query;
...

public class DbUtil {

  /**
  * save someObject to DB
  */
  public static void saveData(SomeClass someObject, String DbFilename) {
    ObjectContainer db=Db4o.openFile(DbFilename);
    try {
      db.set(idGenerator);
    }
    finally {
      db.close();
    }
  } //saveData(SomeClass ..)

  ..

} //DbUtil
    

Comments

Snippets Manager replied on Mon, 2012/05/07 - 2:27pm

idGenerator is an invalid identifier...