當前位置: 首頁>>代碼示例>>Java>>正文


Java Database.close方法代碼示例

本文整理匯總了Java中com.sleepycat.je.Database.close方法的典型用法代碼示例。如果您正苦於以下問題:Java Database.close方法的具體用法?Java Database.close怎麽用?Java Database.close使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.sleepycat.je.Database的用法示例。


在下文中一共展示了Database.close方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getDatabaseStats

import com.sleepycat.je.Database; //導入方法依賴的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();
        }
    }
}
 
開發者ID:nologic,項目名稱:nabs,代碼行數:29,代碼來源:JEMBeanHelper.java

示例2: testEmptyDatabaseSR14744

import com.sleepycat.je.Database; //導入方法依賴的package包/類
public void testEmptyDatabaseSR14744()
throws Throwable {

Database db = null;
try {
    EnvironmentConfig envConfig = getEnvConfig(true);
    env = new Environment(envHome, envConfig);
    db = createDb(true);
    db.sync();
       } finally {
           if (db != null) {
               db.close();
           }

           env.sync();
           env.close();
           env = null;
       }
   }
 
開發者ID:nologic,項目名稱:nabs,代碼行數:20,代碼來源:DeferredWriteTest.java

示例3: showDescOfRelation

import com.sleepycat.je.Database; //導入方法依賴的package包/類
private String showDescOfRelation(String relationName) {
//        MyDbEnv myDbEnv = new MyDbEnv();
        Database relationDB = null;
//        myDbEnv.setup(ExecuteHelpers.myDbEnvPath, READ_ONLY);
        try{
            relationDB = ExecuteHelpers.myDbEnv.getDB("relationDB", READ_ONLY);

            StringBuilder dataEntry = new StringBuilder();
            boolean isRelPresent = ExecuteHelpers.isTablePresent(relationName, dataEntry);
            if(isRelPresent)
                return renderDataEntry(dataEntry);
            else
                return "Relation "+getRel_name()+" not present";
        } finally {
            if(relationDB != null) relationDB.close();
        }
    }
 
開發者ID:prat0318,項目名稱:dbms,代碼行數:18,代碼來源:ShowRel.java

示例4: openTruncated

import com.sleepycat.je.Database; //導入方法依賴的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;
}
 
開發者ID:DevStreet,項目名稱:FinanceAnalytics,代碼行數:12,代碼來源:BerkeleyDBTempTargetRepository.java

示例5: checkIndexExisting

import com.sleepycat.je.Database; //導入方法依賴的package包/類
boolean checkIndexExisting(String name)
{
	if (openIndices.get(name) != null)
	{
		return true;
	}
	else
	{
		DatabaseConfig cfg = new DatabaseConfig();
		cfg.setAllowCreate(false);
		Database db = null;

		try
		{
			db = env.openDatabase(null, DefaultIndexImpl.DB_NAME_PREFIX + name, cfg);
		}
		catch (Exception ex)
		{
		}

		if (db != null)
		{
			try
			{
				db.close();
			}
			catch (Throwable t)
			{
				t.printStackTrace();
			}
			return true;
		}
		else
		{
			return false;
		}
	}
}
 
開發者ID:hypergraphdb,項目名稱:hypergraphdb,代碼行數:39,代碼來源:BJEStorageImplementation.java

示例6: checkForDb

import com.sleepycat.je.Database; //導入方法依賴的package包/類
/**
 * Fail if any db from start - (end -1) doesn't exist
 */
private void checkForDb(String dbName, int start, int end)
    throws DatabaseException {
    /* Dbs start - end -1  should exist. */
    for (int i = start; i < end; i++) {
        try {
            Database checkDb = env.openDatabase(null, dbName + i, null);
            checkDb.close();
        } catch (DatabaseException e) {
            fail(e.getMessage());
        }
    }
}
 
開發者ID:nologic,項目名稱:nabs,代碼行數:16,代碼來源:RecoveryAbortTest.java

示例7: dump

import com.sleepycat.je.Database; //導入方法依賴的package包/類
public void dump()
throws IOException, DatabaseException {

openEnv(true);

Tracer.trace(Level.INFO, DbInternal.envGetEnvironmentImpl(env),
	     "DbDump.dump of " + dbName + " starting");

DatabaseEntry foundKey = new DatabaseEntry();
DatabaseEntry foundData = new DatabaseEntry();

       DatabaseConfig dbConfig = new DatabaseConfig();
       dbConfig.setReadOnly(true);
       DbInternal.setUseExistingConfig(dbConfig, true);
       Database db = env.openDatabase(null, dbName, dbConfig);
dupSort = db.getConfig().getSortedDuplicates();

printHeader(outputFile, dupSort, formatUsingPrintable);

Cursor cursor = db.openCursor(null, null);
while (cursor.getNext(foundKey, foundData, LockMode.DEFAULT) ==
              OperationStatus.SUCCESS) {
    dumpOne(outputFile, foundKey.getData(), formatUsingPrintable);
    dumpOne(outputFile, foundData.getData(), formatUsingPrintable);
}
cursor.close();
db.close();
outputFile.println("DATA=END");

Tracer.trace(Level.INFO, DbInternal.envGetEnvironmentImpl(env),
	     "DbDump.dump of " + dbName + " ending");
   }
 
開發者ID:nologic,項目名稱:nabs,代碼行數:33,代碼來源:DbDump.java

示例8: closeDatabases

import com.sleepycat.je.Database; //導入方法依賴的package包/類
/**
 * Close any databases opened during this operation when it fails.
 * This method should be called if a non-transactional operation fails,
 * since we cannot rely on the transaction abort to cleanup any
 * databases that were opened.
 */
void closeDatabases() {
    for (Database db : databases.keySet()) {
        try {
            db.close();
        } catch (Exception ignored) {
        }
    }
}
 
開發者ID:nologic,項目名稱:nabs,代碼行數:15,代碼來源:Store.java

示例9: removeDatabaseFromCache

import com.sleepycat.je.Database; //導入方法依賴的package包/類
private void removeDatabaseFromCache(Map<String,Database> cache,
                                     String dbName)
    throws DatabaseException {

    synchronized (cache) {
        Database db = cache.get(dbName);
        if (db == null) {
            return;
        }
        db.close();
        cache.remove(dbName);
    }
}
 
開發者ID:prat0318,項目名稱:dbms,代碼行數:14,代碼來源:JEManagedConnection.java

示例10: load

import com.sleepycat.je.Database; //導入方法依賴的package包/類
public boolean load()
throws IOException, DatabaseException {

Tracer.trace(Level.INFO, DbInternal.envGetEnvironmentImpl(env),
	     "DbLoad.load of " + dbName + " starting");

       if (progressInterval > 0) {
           System.out.println("Load start: " + new Date());
       }

       if (textFileMode) {
           formatUsingPrintable = true;
       } else {
           loadHeader();
       }

       if (dbName == null) {
           throw new IllegalArgumentException
               ("Must supply a database name if -l not supplied.");
       }

       DatabaseConfig dbConfig = new DatabaseConfig();
       dbConfig.setSortedDuplicates(dupSort);
       dbConfig.setAllowCreate(true);
       Database db = env.openDatabase(null, dbName, dbConfig);

       loadData(db);

       db.close();

       Tracer.trace(Level.INFO, DbInternal.envGetEnvironmentImpl(env),
                    "DbLoad.load of " + dbName + " ending.");

       if (progressInterval > 0) {
           System.out.println("Load end: " + new Date());
       }

       return true;
   }
 
開發者ID:nologic,項目名稱:nabs,代碼行數:40,代碼來源:DbLoad.java

示例11: testDbLookup

import com.sleepycat.je.Database; //導入方法依賴的package包/類
public void testDbLookup() throws Throwable {
    try {
        EnvironmentConfig envConfig = TestUtils.initEnvConfig();
        envConfig.setTransactional(true);
        envConfig.setConfigParam(EnvironmentParams.NODE_MAX.getName(), "6");
        envConfig.setAllowCreate(true);
        Environment env = new Environment(envHome, envConfig);

        // Make two databases
        DatabaseConfig dbConfig = new DatabaseConfig();
        dbConfig.setTransactional(true);
        dbConfig.setAllowCreate(true);
        Database dbHandleAbcd = env.openDatabase(null, "abcd", dbConfig);
        Database dbHandleXyz = env.openDatabase(null, "xyz", dbConfig);

        // Can we get them back?
        dbConfig.setAllowCreate(false);
        Database newAbcdHandle = env.openDatabase(null, "abcd", dbConfig);
        Database newXyzHandle = env.openDatabase(null, "xyz", dbConfig);

        dbHandleAbcd.close();
        dbHandleXyz.close();
        newAbcdHandle.close();
        newXyzHandle.close();
        env.close();
    } catch (Throwable t) {
        t.printStackTrace();
        throw t;
    }
}
 
開發者ID:nologic,項目名稱:nabs,代碼行數:31,代碼來源:DbTreeTest.java

示例12: testReadCommittedCollection

import com.sleepycat.je.Database; //導入方法依賴的package包/類
public void testReadCommittedCollection()
    throws Exception {

    StoredSortedMap degree2Map = (StoredSortedMap)
        StoredCollections.configuredSortedMap
            (map, CursorConfig.READ_COMMITTED);

    // original map is not read-committed
    assertTrue(!isReadCommitted(map));

    // all read-committed containers are read-uncommitted
    assertTrue(isReadCommitted(degree2Map));
    assertTrue(isReadCommitted
        (StoredCollections.configuredMap
            (map, CursorConfig.READ_COMMITTED)));
    assertTrue(isReadCommitted
        (StoredCollections.configuredCollection
            (map.values(), CursorConfig.READ_COMMITTED)));
    assertTrue(isReadCommitted
        (StoredCollections.configuredSet
            (map.keySet(), CursorConfig.READ_COMMITTED)));
    assertTrue(isReadCommitted
        (StoredCollections.configuredSortedSet
            ((SortedSet) map.keySet(),
             CursorConfig.READ_COMMITTED)));

    if (DbCompat.RECNO_METHOD) {
        // create a list just so we can call configuredList()
        Database listStore = TestStore.RECNO_RENUM.open(env, null);
        List list = new StoredList(listStore, TestStore.VALUE_BINDING,
                                   true);
        assertTrue(isReadCommitted
            (StoredCollections.configuredList
                (list, CursorConfig.READ_COMMITTED)));
        listStore.close();
    }

    map.put(ONE, ONE);
    doReadCommitted(degree2Map, null);
}
 
開發者ID:nologic,項目名稱:nabs,代碼行數:41,代碼來源:TransactionTest.java

示例13: testRemoveNonPersistentDbSR15317

import com.sleepycat.je.Database; //導入方法依賴的package包/類
/**
    * Check that all INs are removed from the INList for a DB that is removed
    * before it is sync'ed (or checkpointed).  Before the bug fix, INs were
    * not removed if the DB root IN was never logged (was still null).  This
    * caused a DatabaseException when evicting, because the evictor expects no
    * INs for deleted DBs on the INList.
    */
   public void testRemoveNonPersistentDbSR15317()
throws Throwable {

Database db = null;
try {
    EnvironmentConfig envConfig = getEnvConfig(true);
           /* Disable compressor for test predictability. */
           envConfig.setConfigParam("je.env.runINCompressor", "false");
    env = new Environment(envHome, envConfig);
    db = createDb(true);
           /* Insert some data to cause eviction later. */
           insert(db, 
                  null,          // txn
                  1,             // start
                  30000,         // end
                  new HashSet(), // expected
                  false);        // useRandom
           db.close();
           env.removeDatabase(null, DBNAME);

           envConfig = env.getConfig();
           /* Switch to a small cache to force eviction. */
           envConfig.setCacheSize(96 * 1024);
           env.setMutableConfig(envConfig);
           for (int i = 0; i < 10; i += 1) {
               env.evictMemory();
           }
       } finally {
           if (env != null) {
               try {
                   env.close();
               } catch (Throwable e) {
                   System.out.println("Ignored: " + e);
               }
               env = null;
           }
       }
   }
 
開發者ID:nologic,項目名稱:nabs,代碼行數:46,代碼來源:DeferredWriteTest.java

示例14: testReadUncommittedCollection

import com.sleepycat.je.Database; //導入方法依賴的package包/類
public void testReadUncommittedCollection()
    throws Exception {

    StoredSortedMap dirtyMap = (StoredSortedMap)
        StoredCollections.configuredSortedMap
            (map, CursorConfig.READ_UNCOMMITTED);

    // original map is not read-uncommitted
    assertTrue(!isReadUncommitted(map));

    // all read-uncommitted containers are read-uncommitted
    assertTrue(isReadUncommitted(dirtyMap));
    assertTrue(isReadUncommitted
        (StoredCollections.configuredMap
            (map, CursorConfig.READ_UNCOMMITTED)));
    assertTrue(isReadUncommitted
        (StoredCollections.configuredCollection
            (map.values(), CursorConfig.READ_UNCOMMITTED)));
    assertTrue(isReadUncommitted
        (StoredCollections.configuredSet
            (map.keySet(), CursorConfig.READ_UNCOMMITTED)));
    assertTrue(isReadUncommitted
        (StoredCollections.configuredSortedSet
            ((SortedSet) map.keySet(), CursorConfig.READ_UNCOMMITTED)));

    if (DbCompat.RECNO_METHOD) {
        // create a list just so we can call configuredList()
        Database listStore = TestStore.RECNO_RENUM.open(env, null);
        List list = new StoredList(listStore, TestStore.VALUE_BINDING,
                                   true);
        assertTrue(isReadUncommitted
            (StoredCollections.configuredList
                (list, CursorConfig.READ_UNCOMMITTED)));
        listStore.close();
    }

    doReadUncommitted(dirtyMap);
}
 
開發者ID:nologic,項目名稱:nabs,代碼行數:39,代碼來源:TransactionTest.java

示例15: run

import com.sleepycat.je.Database; //導入方法依賴的package包/類
public void run(File envHomeDirectory)
    throws DatabaseException, IOException {

    /* Create the environment object. */
    EnvironmentConfig envConfig = new EnvironmentConfig();
    envConfig.setAllowCreate(true);
    Environment env = new Environment(envHomeDirectory, envConfig);

    /* Create the database object. */
    DatabaseConfig dbConfig = new DatabaseConfig();
    dbConfig.setAllowCreate(true);
    Database db = env.openDatabase(null, DB_NAME, dbConfig);

    /* Create the sequence oject. */
    SequenceConfig config = new SequenceConfig();
    config.setAllowCreate(true);
    DatabaseEntry key =
        new DatabaseEntry(KEY_NAME.getBytes("UTF-8"));
    Sequence seq = db.openSequence(null, key, config);

    /* Allocate a few sequence numbers. */
    for (int i = 0; i < 10; i++) {
        long seqnum = seq.get(null, 1);
        System.out.println("Got sequence number: " + seqnum);
    }

    /* Close all. */
    seq.close();
    db.close();
    env.close();
}
 
開發者ID:prat0318,項目名稱:dbms,代碼行數:32,代碼來源:SequenceExample.java


注:本文中的com.sleepycat.je.Database.close方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。