Skip to content

Instantly share code, notes, and snippets.

@kinow
Forked from dagvadorj/gist:3022761
Created November 18, 2013 02:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kinow/7521562 to your computer and use it in GitHub Desktop.
Save kinow/7521562 to your computer and use it in GitHub Desktop.
public static void main(String[] args) throws DatabaseException,
UnsupportedEncodingException {
DatabaseEntry key = new DatabaseEntry();
DatabaseEntry data = new DatabaseEntry();
EnvironmentConfig config = new EnvironmentConfig();
config.setAllowCreate(true);
config.setTransactional(true);
Environment environ = new Environment(new File("sleepydb"), config);
DatabaseConfig databaseConfig = new DatabaseConfig();
databaseConfig.setAllowCreate(true);
Database db = environ.openDatabase(null, "company",
databaseConfig);
db.put(null, new DatabaseEntry("name".getBytes("utf-8")),
new DatabaseEntry("Example company".getBytes("utf-8")));
key.setData("name".getBytes("utf-8"));
db.get(null, key, data, LockMode.DEFAULT);
System.out.println(new String(data.getData(), "utf-8"));
db.close();
environ.close();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment