关于BerkeleyDB的有点和优点,列在以下

JE offers the following major features:

  • Large database support. JE databases efficiently scale from one to millions of records. The size of your JE databases are likely to be limited more by hardware resources than by any limits imposed upon you by JE.

    Databases are described in Databases.

  • Database environments. Database environments provide a unit of encapsulation and management for one or more databases. Environments are also the unit of management for internal resources such as the in-memory cache and the background threads. Finally, you
    use environments to manage concurrency and transactions. Note that all applications using JE are required to use database environments.

    Database environments are described in Database Environments.

  • Multiple thread and process support. JE is designed for multiple threads of control. Both read and write operations can be performed by multiple threads. JE uses record-level locking for high concurrency in threaded applications. Further, JE uses timeouts
    for deadlock detection to help you ensure that two threads of control do not deadlock indefinitely.

    Moreover, JE allows multiple processes to access the same databases. However, in this configuration JE requires that there be no more than one process allowed to write to the database. Read-only processes are guaranteed a consistent, although potentially
    out of date, view of the stored data as of the time that the environment is opened.

  • Transactions. Transactions allow you to treat one or more operations on one or more databases as a single unit of work. JE transactions offer the application developer recoverability, atomicity, and isolation for your database operations.

    Note that transaction protection is optional. Transactions are described in the Berkeley DB, Java Edition Getting Started with Transaction Processing guide.

  • In-memory cache. The cache allows for high speed database access for both read and write operations by avoiding unnecessary disk I/O. The cache will grow on demand up to a pre-configured maximum size. To improve your application's performance immediately
    after startup time, you can preload your cache in order to avoid disk I/O for production requests of your data.

    Cache management is described in Sizing the Cache.

  • Indexes. JE allows you to easily create and maintain secondary indices for your primary data. In this way, you can obtain rapid access to your data through the use of an alternative, or secondary, key.

    How indices work is dependent upon the API you are using. If you are using the DPL, seeWorking
    with Indices
    . Otherwise, see Secondary Databases.

  • Log files. JE databases are stored in one or more numerically-named log files in the environment directory. The log files are write-once and are portable across platforms with different endian-ness.

当然也你能看懂个大概。看程序,在程序中大致翻译了一下

package bdb;

import java.io.File;

import com.sleepycat.je.Database;
import com.sleepycat.je.DatabaseConfig;
import com.sleepycat.je.DatabaseEntry;
import com.sleepycat.je.DatabaseException;
import com.sleepycat.je.Environment;
import com.sleepycat.je.EnvironmentConfig; /**
* BerkeleyDB java的简单使用
* @author Xiaohua
*
*/
public class Test { //此数据库的优点
//大数据的支持,能够支持millions的记录,而且更可能是硬件出现瓶颈而不是je
//数据库环境支持。数据库环境能够一次配置多个数据库或者一个数据库;环境也能够管理并发和事务
//多线程和多进程的支持
//支持事务
//支持内存缓存
//支持索引
//日志记录
private static String dbEnv = "D://dbEnv"; public static void main(String[] args) {
Environment myDbEnvironment = null;
Database myDatabase = null;
try {
EnvironmentConfig envConfig = new EnvironmentConfig();// 配置环境变量
envConfig.setAllowCreate(true);
File f=new File(dbEnv);
if(!f.exists()){
f.mkdirs();
}
myDbEnvironment = new Environment(f, envConfig); } catch (DatabaseException dbe) {
}
try {
DatabaseConfig dbConfig = new DatabaseConfig();// 打开数据库
dbConfig.setAllowCreate(true);
myDatabase = myDbEnvironment.openDatabase(null, "myDatabase",
dbConfig); } catch (DatabaseException dbe2) { }
//存储数据
String aKey = "key4";
String aData = "data";
try {
DatabaseEntry theKey = new DatabaseEntry(aKey.getBytes("UTF-8"));
DatabaseEntry theData = new DatabaseEntry(aData.getBytes("UTF-8"));
myDatabase.put(null, theKey, theData);
// myDbEnvironment.sync();
System.out.println(myDatabase.count());
} catch (Exception e) { } // 关闭,应该会自己主动提交
try {
if (myDatabase != null) {
myDatabase.close();
}
if (myDbEnvironment != null) {
myDbEnvironment.cleanLog(); //  在关闭环境前清理下日志
myDbEnvironment.close();
}
} catch (DatabaseException dbe) { }
}
}

BerkeleyDB java的简单使用的更多相关文章

  1. Java实现简单版SVM

    Java实现简单版SVM 近期的图像分类工作要用到latent svm,为了更加深入了解svm,自己动手实现一个简单版的.         之所以说是简单版,由于没实用到拉格朗日,对偶,核函数等等.而 ...

  2. java实现简单的单点登录

    java实现简单的单点登录 摘要:单点登录(SSO)的技术被越来越广泛地运用到各个领域的软件系统当中.本文从业务的角度分析了单点登录的需求和应用领域:从技术本身的角度分析了单点登录技术的内部机制和实现 ...

  3. Java自定义简单标签

     Java自定义简单标签可以方便的在页面输出信息,并且对于权限的控制,和对于Jsp标签和servlet代码的分离有着很好的作用. 下面将以权限的控制为例自定义一个标签: 一.标签类型 <wxt: ...

  4. 主题:Java WebService 简单实例

    链接地址:主题:Java WebService 简单实例    http://www.iteye.com/topic/1135747 前言:朋友们开始以下教程前,请先看第五大点的注意事项,以避免不必要 ...

  5. java设计模式--简单工厂

    java设计模式--简单工厂 简单工厂不是一个标准的设计模式,但是很常用需要掌握. 在java应用开发中,要"面向接口编程". 1.java中接口的概念: 在java中接口是一种特 ...

  6. JAVA实现简单的四则运算

    GitHub 项目地址 https://github.com/745421831/-/tree/master PSP PSP2.1 Personal Software Process Stages 预 ...

  7. Java的简单类型不能够精确的对浮点数进行运算

    由于Java的简单类型不能够精确的对浮点数进行运算,这个工具类提供精确的浮点数运算,包括加减乘除和四舍五入. import java.math.BigDecimal; /** * 由于Java的简单类 ...

  8. Java秒杀简单设计二:数据库表和Dao层设计

    Java秒杀简单设计二:数据库表Dao层设计 上一篇中搭建springboot项目环境和设计数据库表  https://www.cnblogs.com/taiguyiba/p/9791431.html ...

  9. Java实现简单的RPC框架(美团面试)

    一.RPC简介 RPC,全称为Remote Procedure Call,即远程过程调用,它是一个计算机通信协议.它允许像调用本地服务一样调用远程服务.它可以有不同的实现方式.如RMI(远程方法调用) ...

随机推荐

  1. px,dp,sp以及像素密度

    px px(pixel): 像素,是指在由一个数字序列表示的图像中的一个最小单位.在Android中,无论屏幕密度多少,一个像素单位对应一个屏幕像素单位,不会根据屏幕密度自动缩放,因此一般不推荐使用p ...

  2. Java并发(十五):并发工具类——信号量Semaphore

    先做总结: 1.Semaphore是什么? Semaphore(信号量)是用来控制同时访问特定资源的线程数量,它通过协调各个线程,以保证合理的使用公共资源. 把它比作是控制流量的红绿灯,比如XX马路要 ...

  3. hdu 5204 Rikka with sequence 智商不够系列

    Rikka with sequence Time Limit: 1 Sec  Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.p ...

  4. 关于arcgi s_api_for_flex的总结

    1.flex 的简介 a) Flex是adobe开发的东西,主要特点就是开发一个swf格式的应用,flex可以做桌面的应用和web的应用,但本质差不多. b) Flex采用mxml的格式来进行应用的布 ...

  5. Ubuntu 16.04安装Wine版的微信(deepin-wechat)

    说明: 1.使用的Wine版本是深度出品(Deepin),已经精简了很多没用的配置,使启动能非常快,占用资源小. 2.关于没有.wine文件夹的解决方法:在命令行上运行winecfg: 3.有可能在今 ...

  6. django safe 过滤器--不对字符串进行转义(转)

    unix下的binutils短小精悍,用胶水(俺经常成管道为胶水)紧密结合在一起释放巨大的能量.django的过滤器也学习了这个方式,每个版本的django都自带了一些builtin的filter,当 ...

  7. HDFS API基本操作

    对HDFS API基本操作都是通过 org.apache.hadoop.fs.FileSystem类进行的,以下是一些常见的操作: package HdfsAPI; import java.io.Bu ...

  8. ookla 网络上传下载 PING 测试

    1.登陆http://www.ookla.com/ 2.点选Explore Speedtest Custon 3. 1.start for free 或者 2.measure your network ...

  9. Fiddler2 中文手册

    原文:http://blog.sina.com.cn/s/blog_66a13b8f0100vgfi.html 最近一阵研究 Fiddler2 的使用来着,一开始看起来有点找不着北,索性就根据官网资料 ...

  10. 如何使用花生壳 发布WCF服务 进行外网访问 z

    http://www.cnblogs.com/wanglg/p/5375230.html 当我们发布WCF服务的时候,可以直接通过服务器的域名或者IP进行. 但是如果仅仅是通过花生壳进行域名解析,需要 ...