本文整理匯總了Java中com.sleepycat.je.EnvironmentConfig.setAllowCreate方法的典型用法代碼示例。如果您正苦於以下問題:Java EnvironmentConfig.setAllowCreate方法的具體用法?Java EnvironmentConfig.setAllowCreate怎麽用?Java EnvironmentConfig.setAllowCreate使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.sleepycat.je.EnvironmentConfig
的用法示例。
在下文中一共展示了EnvironmentConfig.setAllowCreate方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: main
import com.sleepycat.je.EnvironmentConfig; //導入方法依賴的package包/類
public static void main(String [] args) throws Exception
{
EnvironmentConfig v_EnvConfig = new EnvironmentConfig();
DatabaseConfig v_DBConfig = new DatabaseConfig();
Berkeley v_Berkeley = new Berkeley();
v_EnvConfig.setAllowCreate(true);
v_DBConfig.setAllowCreate(true);
v_Berkeley.setEnvironmentConfig(v_EnvConfig);
v_Berkeley.setDatabaseConfig( v_DBConfig);
v_Berkeley.setEnvironmentHome( "/Users/hy/WSS/WorkSpace_SearchDesktop/hy.common.berkeley/db");
v_Berkeley.setDatabaseName( "HY");
v_Berkeley.open();
String v_Key = "ZhengWei(HY)";
v_Berkeley.put(v_Key ,Date.getNowTime().getFullMilli());
System.out.println(v_Berkeley.get(v_Key));
}
示例2: UpdateGroundhogScript
import com.sleepycat.je.EnvironmentConfig; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
public UpdateGroundhogScript(File datadir) throws DatabaseException {
environmentConfig = new EnvironmentConfig();
environmentConfig.setAllowCreate(true);
environmentConfig.setTransactional(true);
environmentConfig.setCacheSize(302400000);
// perform other environment configurations
environment = new Environment(datadir, environmentConfig);
List<String> names = environment.getDatabaseNames();
if (names.contains(datadir.getName())) {
environment.renameDatabase(null, datadir.getName(), databaseName);
}
environment.close();
}
示例3: init
import com.sleepycat.je.EnvironmentConfig; //導入方法依賴的package包/類
private void init(File datadir){
try {
environmentConfig = new EnvironmentConfig();
environmentConfig.setAllowCreate(true);
environmentConfig.setTransactional(true);
environmentConfig.setCacheSize(30240000);
environment = new Environment(datadir, environmentConfig);
databaseConfig = new DatabaseConfig();
databaseConfig.setAllowCreate(true);
databaseConfig.setTransactional(true);
openDB();
myIntegerBinding = TupleBinding.getPrimitiveBinding(Integer.class);
myDataBinding = new IntegerToSetOfIntegersBinding();
sh = new IntegerSetStoreShutdown();
sh.g = this;
Runtime.getRuntime().addShutdownHook(sh);
} catch (DatabaseException e) {
e.printStackTrace();
}
}
示例4: init
import com.sleepycat.je.EnvironmentConfig; //導入方法依賴的package包/類
private void init(File datadir){
try {
environmentConfig = new EnvironmentConfig();
environmentConfig.setAllowCreate(true);
environmentConfig.setTransactional(true);
environmentConfig.setCacheSize(30240000);
environment = new Environment(datadir, environmentConfig);
databaseConfig = new DatabaseConfig();
databaseConfig.setAllowCreate(true);
databaseConfig.setTransactional(true);
openDB();
myIntegerBinding = TupleBinding.getPrimitiveBinding(Integer.class);
myDataBinding = new Integer2Integer2IntegerMapBinding();
sh = new CooccurrenceDatabaseShutdown();
sh.c = this;
Runtime.getRuntime().addShutdownHook(sh);
} catch (DatabaseException e) {
e.printStackTrace();
}
}
示例5: initialize
import com.sleepycat.je.EnvironmentConfig; //導入方法依賴的package包/類
private void initialize() throws DatabaseException{
environmentConfig = new EnvironmentConfig();
environmentConfig.setAllowCreate(true);
environmentConfig.setTransactional(false);
environmentConfig.setCacheSize(cachesize);
// perform other environment configurations
environment = new Environment(datadir, environmentConfig);
databaseConfig = new DatabaseConfig();
databaseConfig.setAllowCreate(true);
databaseConfig.setTransactional(false);
// perform other database configurations
openDB();
// add a shutdown hook to close the database when the VM is terminated
sh = new Shutdown();
sh.cache = this;
Runtime.getRuntime().addShutdownHook(sh);
}
示例6: init
import com.sleepycat.je.EnvironmentConfig; //導入方法依賴的package包/類
@Override
public void init() {
EnvironmentConfig envConfig = new EnvironmentConfig();
commonConfig(envConfig);
envConfig.setCachePercent(config.getCachePercent());
envConfig.setAllowCreate(true);
if (config.isTransactional()) {
envConfig.setCachePercent(config.getCachePercent());
envConfig.setTransactional(config.isTransactional());
envConfig.setTxnTimeout(config.getTxnTimeout(), TimeUnit.SECONDS);
this.durability = config.isCommitSync() ? Durability.COMMIT_SYNC : Durability.COMMIT_NO_SYNC;
envConfig.setDurability(this.durability);
}
File repo_dir = new File(config.getRepoDir());
if (!repo_dir.exists()) {
repo_dir.mkdirs();
}
this.env = new Environment(repo_dir, envConfig);
cef = new CommandHandlerFactoryBDBImpl();
cursorFactoryBDBImp = new CursorFactoryBDBImp();
}
示例7: WebGraph
import com.sleepycat.je.EnvironmentConfig; //導入方法依賴的package包/類
/**
* 構造函數
*/
public WebGraph(String dbDir) throws DatabaseException {
File envDir = new File(dbDir);
EnvironmentConfig envConfig = new EnvironmentConfig();
envConfig.setTransactional(false);
envConfig.setAllowCreate(true);
Environment env = new Environment(envDir, envConfig);
StoreConfig storeConfig = new StoreConfig();
storeConfig.setAllowCreate(true);
storeConfig.setTransactional(false);
store = new EntityStore(env, "classDb", storeConfig);
outLinkIndex = store.getPrimaryIndex(String.class, Link.class);
inLinkIndex = store.getSecondaryIndex(outLinkIndex, String.class, "toURL");
}
示例8: AbstractFrontier
import com.sleepycat.je.EnvironmentConfig; //導入方法依賴的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);
}
示例9: openEnv
import com.sleepycat.je.EnvironmentConfig; //導入方法依賴的package包/類
/**
* Opens the environment and db.
*/
private void openEnv(boolean transactional, boolean dups, String nodeMax)
throws DatabaseException {
hasDups = dups;
EnvironmentConfig envConfig = TestUtils.initEnvConfig();
envConfig.setTransactional(transactional);
envConfig.setConfigParam
(EnvironmentParams.ENV_RUN_INCOMPRESSOR.getName(), "false");
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(dups);
dbConfig.setAllowCreate(true);
db = env.openDatabase(null, "testDB", dbConfig);
}
示例10: main
import com.sleepycat.je.EnvironmentConfig; //導入方法依賴的package包/類
/** Creates the environment and runs a transaction */
public static void main(String[] argv)
throws Exception {
String dir = "./tmp";
// environment is transactional
EnvironmentConfig envConfig = new EnvironmentConfig();
envConfig.setTransactional(true);
if (create) {
envConfig.setAllowCreate(true);
}
Environment env = new Environment(new File(dir), envConfig);
// create the application and run a transaction
HelloDatabaseWorld worker = new HelloDatabaseWorld(env);
TransactionRunner runner = new TransactionRunner(env);
try {
// open and access the database within a transaction
runner.run(worker);
} finally {
// close the database outside the transaction
worker.close();
}
}
示例11: initDbs
import com.sleepycat.je.EnvironmentConfig; //導入方法依賴的package包/類
/**
* Set up the environment and db.
*/
private void initDbs(int nDumps, Hashtable[] dataMaps)
throws DatabaseException {
EnvironmentConfig envConfig = TestUtils.initEnvConfig();
envConfig.setConfigParam(EnvironmentParams.NODE_MAX.getName(), "6");
envConfig.setAllowCreate(true);
env = new Environment(envHome, envConfig);
/* Make a db and open it. */
for (int i = 0; i < nDumps; i += 1) {
DatabaseConfig dbConfig = new DatabaseConfig();
dbConfig.setAllowCreate(true);
dbConfig.setSortedDuplicates(true);
Database myDb = env.openDatabase(null, dbName + i, dbConfig);
Cursor cursor = myDb.openCursor(null, null);
doLargePut(dataMaps[i], cursor, N_KEYS);
cursor.close();
myDb.close();
}
}
示例12: initEngine
import com.sleepycat.je.EnvironmentConfig; //導入方法依賴的package包/類
public boolean initEngine(File envHome)
{
EnvironmentConfig envConfig = new EnvironmentConfig();
m_DbConfig = new DatabaseConfig();
// If the environment is read-only, then
// make the databases read-only too.
envConfig.setReadOnly(false);
m_DbConfig.setReadOnly(false);
// If the environment is opened for write, then we want to be
// able to create the environment and databases if
// they do not exist.
envConfig.setAllowCreate(true);
m_DbConfig.setAllowCreate(true);
// Allow transactions if we are writing to the database
envConfig.setTransactional(false);
m_DbConfig.setTransactional(false);
m_DbConfig.setDeferredWrite(true);
envConfig.setLocking(false); // No locking
m_DbConfig.setBtreeComparator(BtreeKeyComparator.class);
// Open the environment
try
{
m_env = new Environment(envHome, envConfig);
return true;
}
catch(DatabaseException e)
{
return false;
}
}
示例13: start
import com.sleepycat.je.EnvironmentConfig; //導入方法依賴的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; // 設定是否運行
}
示例14: init
import com.sleepycat.je.EnvironmentConfig; //導入方法依賴的package包/類
public void init() throws EnvironmentLockedException, DatabaseException {
EnvironmentConfig environmentConfig = new EnvironmentConfig();
DatabaseConfig dbConfig = new DatabaseConfig();
dbConfig.setAllowCreate(true);
dbConfig.setSortedDuplicates(true);
environmentConfig.setReadOnly(false);
environmentConfig.setAllowCreate(true);
// Open the environment and entity store
if (!dataDir.exists()) {
dataDir.mkdirs();
}
environment = new Environment(dataDir, environmentConfig);
// Database database = environment.openDatabase(transaction, "BDB", dbConfig);
this.bdb = new BdbDatabaseImpl(environment, "DEFAULT");
}
示例15: constructDatabaseEnvironmentImpl
import com.sleepycat.je.EnvironmentConfig; //導入方法依賴的package包/類
private static Environment constructDatabaseEnvironmentImpl(final File dbDir, final boolean transactional) {
if (!dbDir.exists()) {
dbDir.mkdirs();
}
final EnvironmentConfig envConfig = new EnvironmentConfig();
envConfig.setAllowCreate(true);
envConfig.setTransactional(transactional);
return new Environment(dbDir, envConfig);
}