欢迎投稿

今日深度:

BerkeleyDB java的简单使用,berkeleydbjava

BerkeleyDB java的简单使用,berkeleydbjava


关于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) {

		}
	}
}



java语言的前景怎

你好:
讨论前景,没有意义,什么语言都会有流行的时期,当然也会有没落的时期,就现阶段,学好JAVA就行,因为他很流行很主流,掌握学习方法最重要,工作中用的语言还有很多,总之学吧。不要去考虑什么前景,学好就行,因为你不可能之用一种语言。
 

可以人,给指点一下,看不懂的莫喷

Java是一种可以撰写跨平台应用软件的面向对象的程序设计语言,是由Sun Microsystems公司于1995年5月推出的Java程序设计语言和(即JavaSE, JavaEE, JavaME)的总称。Java 技术具有卓越的通用性、高效性、平台移植性和安全性,广泛应用于个人PC、数据中心、游戏控制台、科学超级计算机、移动电话和互联网,同时拥有全球最大的开发者专业社群。在全球云计算和移动互联网的产业环境下,Java更具备了显著优势和广阔前景。
发展前景  自从sun被甲骨文收购以后,java的发展前景就变得扑朔迷离起来,很多程序开发者都感到很迷惑。2010年4月9日,被称为Java之父的JamesGosling又在个人博客上宣布离开Oracle,这一事件更为Java的前景增加了一层迷雾。但是在进入5月份之后,一切开始变得明朗起来。
  在Oracle的活动发布网站上,连续发布了多个关于Java的推广活动。5月12日,Oracle主要产品负责人DaveHofert将大谈对JavaSE商业应用的改进和革新。根据宣传资料,在这次演讲中,DaveHofert将提到以下问题:商业版与社区版本之间平台支持的差异。如何获得专家帮助,以帮助企业增强其Java应用。对于旧版本的安全修补问题。可使用的发布工具和更新。6月18、19、20、27日,将分别在举行Oracle、Sun专家与用户见面会,在见面会上与用户一起探讨Java的发展路线。主要讨论的问题包括Oracle将如何继续投资和改进Java技术,并且还会向用户通报JavaSE、JavaME专家团队的最新消息、JavaFX和JDK7最新的消息,以及OracleBerkeley DB的相关信息。5月3日,已经离开Oracle近一个月的Java之父JamesGosling在他的博客上表达了对NetBeans 6.9 和 FX1.3发布的关心。这两个项目最新版本的发布,可以证明Oracle已经开始兑现当初的承诺。JamesGosling在其早期的博客中,也透露了不会放弃Java事业,只是需要解决一些与Oracle之间的法律问题。这一切迹象表明,Oracle绝对不会轻易放弃Java这块巨大的蛋糕,并且Oracle也开始逐渐学会了对开源社区的尊重。首先在JDK的商业版本方面,Oracle将会继续深入挖掘Java的商业利益,与其固有产品进行更深入的整合。在社区版本方面,Oracle将与Java开发者一起探讨和研发Java的技术。这里需要特别提到的一个产品是Oracle BerkeleyDB,该产品是Oracle一直支持的一个开源非关系数据库产品,在NOSQL大行其道的今天,如果Oracle能够将BerkeleyDB与Java进行深入整合,将会为Java带来更多的活力和生命。从JamesGosling的表现来看,他似乎与Oracle之间已经达成某种谅解,并且有进一步合作的可能性
 

www.htsjk.Com true http://www.htsjk.com/shujukunews/3979.html NewsArticle BerkeleyDB java的简单使用,berkeleydbjava 关于BerkeleyDB的有点和好处,列在下面 JE offers the following major features: Large database support. JE databases efficiently scale from one to millions of records. The size of yo...
评论暂时关闭