本文整理匯總了Java中com.sleepycat.je.Environment.openDatabase方法的典型用法代碼示例。如果您正苦於以下問題:Java Environment.openDatabase方法的具體用法?Java Environment.openDatabase怎麽用?Java Environment.openDatabase使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.sleepycat.je.Environment
的用法示例。
在下文中一共展示了Environment.openDatabase方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: AbstractFrontier
import com.sleepycat.je.Environment; //導入方法依賴的package包/類
public AbstractFrontier(String homeDirectory) {
EnvironmentConfig envConfig = new EnvironmentConfig();
envConfig.setTransactional(true);
envConfig.setAllowCreate(true);
env = new Environment(new File(homeDirectory), envConfig);
// 設置databaseconfig
DatabaseConfig dbConfig = new DatabaseConfig();
dbConfig.setTransactional(true);
dbConfig.setAllowCreate(true);
// 打開
catalogdatabase = env.openDatabase(null, CLASS_CATALOG, dbConfig);
javaCatalog = new StoredClassCatalog(catalogdatabase);
// 設置databaseconfig
DatabaseConfig dbConfig0 = new DatabaseConfig();
dbConfig0.setTransactional(true);
dbConfig0.setAllowCreate(true);
database = env.openDatabase(null, "URL", dbConfig0);
}
示例2: ClassCatalog
import com.sleepycat.je.Environment; //導入方法依賴的package包/類
ClassCatalog(String directory, EnvironmentConfig environmentConfig, DatabaseConfig dbConfig) {
// This should be main database directory
dirClassLoader = new DirClassLoader(directory);
// Open the environment in subdirectory of the above
String classesDir = directory + java.io.File.separator + "classes";
RelDatabase.mkdir(classesDir);
environment = new Environment(new File(classesDir), environmentConfig);
// Open the class catalog db. This is used to optimize class serialization.
classCatalogDb = environment.openDatabase(null, "_ClassCatalog", dbConfig);
// Create our class catalog
classCatalog = new StoredClassCatalog(classCatalogDb);
// Need a serial binding for metadata
relvarMetadataBinding = new SerialBinding<RelvarMetadata>(classCatalog, RelvarMetadata.class);
// Need serial binding for data
tupleBinding = new SerialBinding<ValueTuple>(classCatalog, ValueTuple.class) {
public ClassLoader getClassLoader() {
return dirClassLoader;
}
};
}
示例3: openEnv
import com.sleepycat.je.Environment; //導入方法依賴的package包/類
/**
* Opens the environment and db.
*/
private void openEnv(boolean transactional, String nodeMax)
throws DatabaseException {
EnvironmentConfig envConfig = TestUtils.initEnvConfig();
envConfig.setTransactional(transactional);
envConfig.setConfigParam
(EnvironmentParams.ENV_RUN_INCOMPRESSOR.getName(), "true");
if (nodeMax != null) {
envConfig.setConfigParam
(EnvironmentParams.NODE_MAX.getName(), nodeMax);
envConfig.setConfigParam
(EnvironmentParams.NODE_MAX_DUPTREE.getName(), nodeMax);
}
envConfig.setAllowCreate(true);
env = new Environment(envHome, envConfig);
/* Make a db and open it. */
DatabaseConfig dbConfig = new DatabaseConfig();
dbConfig.setTransactional(transactional);
dbConfig.setSortedDuplicates(useDups);
dbConfig.setAllowCreate(true);
db = env.openDatabase(null, "testDB", dbConfig);
}
示例4: setUp
import com.sleepycat.je.Environment; //導入方法依賴的package包/類
public void setUp()
throws IOException, DatabaseException {
IN.ACCUMULATED_LIMIT = 0;
Txn.ACCUMULATED_LIMIT = 0;
TestUtils.removeFiles("Setup", envHome, FileManager.JE_SUFFIX);
EnvironmentConfig envConfig = TestUtils.initEnvConfig();
envConfig.setConfigParam(EnvironmentParams.NODE_MAX.getName(), "6");
envConfig.setTransactional(true);
envConfig.setAllowCreate(true);
env = new Environment(envHome, envConfig);
DatabaseConfig dbConfig = new DatabaseConfig();
dbConfig.setTransactional(true);
dbConfig.setAllowCreate(true);
db = env.openDatabase(null, "foo", dbConfig);
}
示例5: tempBufferInitEnvInternal
import com.sleepycat.je.Environment; //導入方法依賴的package包/類
private void tempBufferInitEnvInternal(String buffSize, String cacheSize)
throws DatabaseException {
EnvironmentConfig envConfig = TestUtils.initEnvConfig();
envConfig.setTransactional(true);
envConfig.setAllowCreate(true);
if (!buffSize.equals("0")) {
envConfig.setConfigParam("je.log.totalBufferBytes", buffSize);
}
if (!cacheSize.equals("0")) {
envConfig.setConfigParam("je.maxMemory", cacheSize);
}
env = new Environment(envHome, envConfig);
DatabaseConfig dbConfig = new DatabaseConfig();
dbConfig.setAllowCreate(true);
dbConfig.setSortedDuplicates(true);
dbConfig.setTransactional(true);
db = env.openDatabase(null, "InsertAndDelete", dbConfig);
}
示例6: getDatabaseStats
import com.sleepycat.je.Environment; //導入方法依賴的package包/類
/**
* Helper to get statistics for a given database.
* @param params operation parameters
* @return DatabaseStats object
*/
private DatabaseStats getDatabaseStats(Environment targetEnv,
Object [] params)
throws IllegalArgumentException,
DatabaseException {
if ((params == null) || (params.length < 3)) {
return null;
}
String dbName = (String)params[2];
Database db = null;
try {
DatabaseConfig dbConfig = new DatabaseConfig();
dbConfig.setReadOnly(true);
DbInternal.setUseExistingConfig(dbConfig, true);
db = targetEnv.openDatabase(null, dbName, dbConfig);
return db.getStats(getStatsConfig(params));
} finally {
if (db != null) {
db.close();
}
}
}
示例7: open
import com.sleepycat.je.Environment; //導入方法依賴的package包/類
/**
* ???
*/
public void open() {
if (!isClosed()) {
NeoLogger.warn("This backend is already open");
}
try {
environment = new Environment(file, environmentConfig);
this.containers = environment.openDatabase(null, KEY_CONTAINER, databaseConfig);
this.instances = environment.openDatabase(null, KEY_INSTANCE_OF, databaseConfig);
this.features = environment.openDatabase(null, KEY_FEATURES, databaseConfig);
this.multivaluedFeatures = environment.openDatabase(null, KEY_MULTIVALUED_FEATURES, databaseConfig);
isClosed = false;
}
catch (DatabaseException e) {
NeoLogger.error(e);
}
}
示例8: start
import com.sleepycat.je.Environment; //導入方法依賴的package包/類
/**
* 打開數據庫方法
*/
public static void start(String path) {
if (isrunning) {
return;
}
/******************** 文件處理 ***********************/
File envDir = new File(path);// 操作文件
if (!envDir.exists())// 判斷文件路徑是否存在,不存在則創建
{
envDir.mkdir();// 創建
}
/******************** 環境配置 ***********************/
EnvironmentConfig envConfig = new EnvironmentConfig();
envConfig.setTransactional(false); // 不進行事務處理
envConfig.setAllowCreate(true); // 如果不存在則創建一個
exampleEnv = new Environment(envDir, envConfig);// 通過路徑,設置屬性進行創建
/******************* 創建適配器對象 ******************/
DatabaseConfig dbConfig = new DatabaseConfig();
dbConfig.setTransactional(false); // 不進行事務處理
dbConfig.setAllowCreate(true);// 如果不存在則創建一個
dbConfig.setSortedDuplicates(true);// 數據分類
bdb = exampleEnv.openDatabase(null, "simpleDb", dbConfig); // 使用適配器打開數據庫
isrunning = true; // 設定是否運行
}
示例9: openTruncated
import com.sleepycat.je.Environment; //導入方法依賴的package包/類
private static Database openTruncated(final Environment environment, final DatabaseConfig config, final String name) {
s_logger.debug("Opening {}", name);
Database handle = environment.openDatabase(null, name, config);
if (handle.count() > 0) {
handle.close();
s_logger.info("Truncating existing {}", name);
environment.truncateDatabase(null, name, false);
handle = environment.openDatabase(null, name, config);
}
return handle;
}
示例10: BerkeleyDB
import com.sleepycat.je.Environment; //導入方法依賴的package包/類
public BerkeleyDB(String filePath, String databaseName) {
EnvironmentConfig envConfig = new EnvironmentConfig();
envConfig.setAllowCreate(true);
environment = new Environment(new File(filePath), envConfig);
DatabaseConfig dbConfig = new DatabaseConfig();
dbConfig.setAllowCreate(true);
database = environment.openDatabase(null, databaseName, dbConfig);
}
示例11: initialize
import com.sleepycat.je.Environment; //導入方法依賴的package包/類
/**
* This method is invoked by the kernel to initialize the storage.
*
* @param arguments The arguments with which this storage is to be
* initialized.
* @return True if the storage was initialized successfully.
*/
public boolean initialize(String filePath) {
//clock = System.currentTimeMillis();
countUpdates = 0;
annotationsTime = 0;
scaffoldTime = 0;
clockScaffold = 0;
clockAnnotations = 0;
scaffoldInMemory = new HashMap<Integer, Pair<SortedSet<Integer>, SortedSet<Integer>>>();
edgesInMemory = 0;
hashToID = new HashMap<String, Integer>();
idToHash = new HashMap<Integer, String>();
alreadyRenamed = new Vector<String>();
compresser = new Deflater(Deflater.BEST_COMPRESSION);
W=10;
L=5;
nextVertexID = 0;
try {
benchmarks = new PrintWriter("/Users/melanie/Documents/benchmarks/compression_time_berkeleyDB.txt", "UTF-8");
// Open the environment. Create it if it does not already exist.
EnvironmentConfig envConfig = new EnvironmentConfig();
envConfig.setAllowCreate(true);
DatabaseEnvironment1 = new Environment(new File(filePath + "/scaffold"),
envConfig);
DatabaseEnvironment2 = new Environment(new File(filePath + "/annotations"),
envConfig);
// Open the databases. Create it if it does not already exist.
DatabaseConfig DatabaseConfig1 = new DatabaseConfig();
DatabaseConfig1.setAllowCreate(true);
scaffoldDatabase = DatabaseEnvironment1.openDatabase(null, "spade_scaffold", DatabaseConfig1);
annotationsDatabase = DatabaseEnvironment2.openDatabase(null, "spade_annotations", DatabaseConfig1);
return true;
} catch (Exception ex) {
// Exception handling goes here
logger.log(Level.SEVERE, "Compressed Storage Initialized not successful!", ex);
return false;
}
}
示例12: open
import com.sleepycat.je.Environment; //導入方法依賴的package包/類
private void open(boolean allowDuplicates)
throws Exception {
EnvironmentConfig envConfig = TestUtils.initEnvConfig();
envConfig.setConfigParam
(EnvironmentParams.NODE_MAX.getName(), String.valueOf(NODE_MAX));
/*
envConfig.setConfigParam
(EnvironmentParams.MAX_MEMORY.getName(), "10000000");
envConfig.setConfigParam
(EnvironmentParams.ENV_RUN_CLEANER.getName(), "false");
envConfig.setConfigParam
(EnvironmentParams.ENV_RUN_CHECKPOINTER.getName(), "false");
*/
envConfig.setConfigParam
(EnvironmentParams.ENV_RUN_EVICTOR.getName(), "false");
envConfig.setConfigParam
(EnvironmentParams.ENV_RUN_INCOMPRESSOR.getName(), "false");
envConfig.setTransactional(true);
envConfig.setAllowCreate(true);
env = new Environment(envHome, envConfig);
DatabaseConfig dbConfig = new DatabaseConfig();
dbConfig.setAllowCreate(true);
dbConfig.setExclusiveCreate(false);
dbConfig.setTransactional(true);
dbConfig.setSortedDuplicates(allowDuplicates);
db = env.openDatabase(null, "testDb", dbConfig);
}
示例13: init
import com.sleepycat.je.Environment; //導入方法依賴的package包/類
private void init()
throws DatabaseException {
EnvironmentConfig envConfig = TestUtils.initEnvConfig();
envConfig.setAllowCreate(true);
envConfig.setTransactional(true);
env = new Environment(envHome, envConfig);
DatabaseConfig dbConfig = new DatabaseConfig();
dbConfig.setAllowCreate(true);
dbConfig.setTransactional(true);
db = env.openDatabase(null, "foo", dbConfig);
}
示例14: getDatabaseStats
import com.sleepycat.je.Environment; //導入方法依賴的package包/類
/**
* Helper to get statistics for a given database.
* @param params operation parameters
* @return DatabaseStats object
*/
private DatabaseStats getDatabaseStats(Environment targetEnv,
Object[] params)
throws IllegalArgumentException,
DatabaseNotFoundException,
DatabaseException {
if ((params == null) || (params.length < 3)) {
return null;
}
String dbName = (String)params[2];
Database db = null;
try {
DatabaseConfig dbConfig = new DatabaseConfig();
dbConfig.setReadOnly(true);
DbInternal.setUseExistingConfig(dbConfig, true);
try {
db = targetEnv.openDatabase(null, dbName, dbConfig);
} catch (DatabaseExistsException e) {
/* Should never happen, ExlcusiveCreate is false. */
throw EnvironmentFailureException.unexpectedException(e);
}
return db.getStats(getStatsConfig(params));
} finally {
if (db != null) {
db.close();
}
}
}
示例15: openEnv
import com.sleepycat.je.Environment; //導入方法依賴的package包/類
private static void openEnv() throws DatabaseException {
System.out.println("opening env");
// Set up the environment.
EnvironmentConfig myEnvConfig = new EnvironmentConfig();
myEnvConfig.setAllowCreate(true);
myEnvConfig.setTransactional(true);
// Environment handles are free-threaded in JE,
// so we do not have to do anything to cause the
// environment handle to be free-threaded.
// Set up the database
DatabaseConfig myDbConfig = new DatabaseConfig();
myDbConfig.setAllowCreate(true);
myDbConfig.setTransactional(true);
myDbConfig.setSortedDuplicates(true);
// no DatabaseConfig.setThreaded() method available.
// db handles in java are free-threaded so long as the
// env is also free-threaded.
// Open the environment
myEnv = new Environment(new File(myEnvPath), // Env home
myEnvConfig);
// Open the database. Do not provide a txn handle. This open
// is autocommitted because DatabaseConfig.setTransactional()
// is true.
myDb = myEnv.openDatabase(null, // txn handle
dbName, // Database file name
myDbConfig);
// Used by the bind API for serializing objects
// Class database must not support duplicates
myDbConfig.setSortedDuplicates(false);
myClassDb = myEnv.openDatabase(null, // txn handle
cdbName, // Database file name
myDbConfig);
}