没有合适的资源?快使用搜索试试~ 我知道了~
BerkeleyDB-Core-JAVA-GSG.pdf
需积分: 9 8 下载量 117 浏览量
2008-10-14
11:22:51
上传
评论
收藏 491KB PDF 举报
温馨提示
试读
98页
文件类型的DB,存取速度快,操作方便,是以map方式key-value方式存取数据.兄弟大家共享!
资源推荐
资源详情
资源评论
M a k e r s of B e r k e l e y DB
Getting Started
with Berkeley DB
for Java
.
Legal Notice
This documentation is distributed under the terms of the Sleepycat public license. You may review the terms
of this license at: http://www.sleepycat.com/download/oslicense.html
Sleepycat Software, Berkeley DB, Berkeley DB XML and the Sleepycat logo are trademarks or service marks of
Sleepycat Software, Inc. All rights to these marks are reserved. No third-party use is permitted without the
express prior written consent of Sleepycat Software, Inc.
Java™ and all Java-based marks are a trademark or registered trademark of Sun Microsystems, Inc, in the United
States and other countries.
To obtain a copy of this document's original source code, please write to
<support@sleepycat.com>
.
Published 11/9/2005
TableofContents
Preface .............................................................................................. iv
Conventions Used in this Book ............................................................. iv
1. Introduction to Berkeley DB .................................................................. 1
About This Manual ........................................................................... 2
Berkeley DB Concepts ....................................................................... 2
Access Methods ............................................................................... 4
Selecting Access Methods ............................................................ 4
Choosing between BTree and Hash ................................................. 5
Choosing between Queue and Recno ............................................... 5
Database Limits and Portability ............................................................ 6
Environments ................................................................................. 6
Exception Handling .......................................................................... 7
Error Returns .................................................................................. 8
Getting and Using DB ....................................................................... 8
2. Databases ......................................................................................... 9
Opening Databases ........................................................................... 9
Closing Databases ........................................................................... 10
Database Properties ........................................................................ 11
Administrative Methods .................................................................... 12
Error Reporting Functions ................................................................. 13
Managing Databases in Environments .................................................... 14
Database Example .......................................................................... 16
3. Database Records .............................................................................. 19
Using Database Records .................................................................... 19
Reading and Writing Database Records ................................................. 20
Writing Records to the Database .................................................. 21
Getting Records from the Database ............................................... 22
Deleting Records ..................................................................... 23
Data Persistence ..................................................................... 24
Using the BIND APIs ......................................................................... 25
Numerical and String Objects ...................................................... 25
Serializable Complex Objects ...................................................... 27
Usage Caveats .................................................................. 28
Serializing Objects ............................................................. 28
Deserializing Objects .......................................................... 31
Custom Tuple Bindings .............................................................. 32
Database Usage Example .................................................................. 35
4. Using Cursors ................................................................................... 47
Opening and Closing Cursors .............................................................. 47
Getting Records Using the Cursor ........................................................ 48
Searching for Records ............................................................... 50
Working with Duplicate Records ................................................... 53
Putting Records Using Cursors ............................................................ 55
Deleting Records Using Cursors ........................................................... 57
Replacing Records Using Cursors ......................................................... 58
Cursor Example ............................................................................. 59
Page iiGetting Started with DB11/9/2005
5. Secondary Databases .......................................................................... 64
Opening and Closing Secondary Databases ............................................. 64
Implementing Key Creators .............................................................. 67
Secondary Database Properties ........................................................... 70
Reading Secondary Databases ............................................................ 70
Deleting Secondary Database Records ................................................... 71
Using Secondary Cursors .................................................................. 72
Database Joins .............................................................................. 73
Using Join Cursors .................................................................... 74
JoinCursor Properties ................................................................ 76
Secondary Database Example ............................................................. 77
Opening Secondary Databases with MyDbs ....................................... 78
Using Secondary Databases with ExampleDatabaseRead ....................... 82
6. Database Configuration ....................................................................... 85
Setting the Page Size ....................................................................... 85
Overflow Pages ....................................................................... 85
Locking ................................................................................. 86
IO Efficiency .......................................................................... 87
Page Sizing Advice ................................................................... 87
Selecting the Cache Size .................................................................. 88
BTree Configuration ........................................................................ 88
Allowing Duplicate Records ......................................................... 89
Sorted Duplicates .............................................................. 89
Unsorted Duplicates ........................................................... 89
Configuring a Database to Support Duplicates ............................ 90
Setting Comparison Functions ...................................................... 91
Creating Java Comparators .................................................. 92
Page iiiGetting Started with DB11/9/2005
Preface
Welcome to Berkeley DB (DB). This document introduces DB, version 4.4. It is intended
to provide a rapid introduction to the DB API set and related concepts. The goal of this
document is to provide you with an efficient mechanism with which you can evaluate DB
against your project's technical requirements. As such, this document is intended for Java
developers and senior software architects who are looking for an in-process data
management solution. No prior experience with Sleepycat technologies is expected or
required.
ConventionsUsedinthisBook
The following typographical conventions are used within in this manual:
Class names are represented in
monospaced font
, as are
method names
. For example: "The
Database()
constructor returns a
Database
class object."
Variable or non-literal text is presented in italics. For example: "Go to your DB_INSTALL
directory."
Program examples are displayed in a
monospaced font
on a shaded background. For
example:
import com.sleepycat.db.DatabaseConfig;
...
// Allow the database to be created.
DatabaseConfig myDbConfig = new DatabaseConfig();
myDbConfig.setAllowCreate(true);
In some situations, programming examples are updated from one chapter to the next.
When this occurs, the new code is presented in
monospaced bold
font. For example:
import com.sleepycat.db.Database;
import com.sleepycat.db.DatabaseConfig;
...
// Allow the database to be created.
DatabaseConfig myDbConfig = new DatabaseConfig();
myDbConfig.setAllowCreate(true);
Database myDb = new Database("mydb.db", null, myDbConfig);
Finally, notes of interest are represented using a note block such as this.
☞
Page ivGetting Started with DB11/9/2005
剩余97页未读,继续阅读
资源评论
tanhong1977
- 粉丝: 0
- 资源: 4
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功