2011-08-06 3 views
1

내가 데이터베이스 /home/panayk/Desktop/panag_3/panag_3.tld을 찾을 수 없습니다com.sleepycat.je.DatabaseNotFoundException 데이터베이스는

$ db_verify /home/panayk/Desktop/panag_3/panag_3.tld 
Verification of /home/panayk/Desktop/panag_3/panag_3.tld succeeded. 

버클리하여 엽니 다 거부합니다. 여기

내 수입은 다음과 같습니다

final File file = new File(filename); 

final String homeDirectoryName = file.getParent(); 
final File homeDirectory = new File(homeDirectoryName); 

LOGGER.info("Opening environment in {}.", homeDirectoryName); 

final EnvironmentConfig environmentConfig = new EnvironmentConfig(); 
environmentConfig.setTransactional(true); 
environmentConfig.setAllowCreate(true); 

final DatabaseConfig dbConfig = new DatabaseConfig(); 
dbConfig.setTransactional(true); 
dbConfig.setAllowCreate(false); 

environment = new Environment(homeDirectory, environmentConfig); 

LOGGER.info("Opening database in {}.", filename); 
database = environment.openDatabase(null, filename, dbConfig); 

catalog = new StoredClassCatalog(database); 

final EntryBinding keyBinding = new SerialBinding(catalog, Object.class); 
final EntryBinding valueBinding = new SerialBinding(catalog, Object.class); 

map = new StoredMap(database, keyBinding, valueBinding, true); 

이 로그입니다 :

15:55:54,498 INFO TLDImporter:38 - Opening environment in /home/panayk/Desktop/panag_3. 
15:55:54,779 INFO TLDImporter:50 - Opening database in /home/panayk/Desktop/panag_3/panag_3.tld. 

그리고 여기에 예외 :

여기

import com.sleepycat.bind.EntryBinding; 
import com.sleepycat.bind.serial.SerialBinding; 
import com.sleepycat.bind.serial.StoredClassCatalog; 
import com.sleepycat.collections.StoredMap; 
import com.sleepycat.collections.TransactionRunner; 
import com.sleepycat.collections.TransactionWorker; 
import com.sleepycat.je.Database; 
import com.sleepycat.je.DatabaseConfig; 
import com.sleepycat.je.DatabaseException; 
import com.sleepycat.je.Environment; 
import com.sleepycat.je.EnvironmentConfig; 

그리고 나의 코드

com.sleepycat.je.DatabaseNotFoundException: (JE 4.1.10) Database /home/panayk/Desktop/panag_3/panag_3.tld not found. 
    at com.sleepycat.je.Environment.setupDatabase(Environment.java:790) 
    at com.sleepycat.je.Environment.openDatabase(Environment.java:536) 
    at gr.panayk.vinyls.importer.TLDImporter.<init>(TLDImporter.java:51) 
    at gr.panayk.vinyls.persistence.HibernateEntityRegistry.initialize(HibernateEntityRegistry.java:36) 
    ... 60 more 

무엇이 잘못 되었나요? 파일이 분명히 존재합니다.

답변

0

final DatabaseConfig dbConfig = new DatabaseConfig(); 
dbConfig.setTransactional(true); 
dbConfig.setAllowCreate(false); 

http://www.javasourcecode.org/html/open-source/berkeleydb/berkeleydb-4.1.6/com/sleepycat/je/Environment.java.html

/* No database. Create if we're allowed to. */ 
if (dbConfig.getAllowCreate()) { 

    /* 
    * We're going to have to do some writing. Switch to a 
    * writable locker if we don't already have one. Note 
    * that the existing locker does not hold the handle lock 
    * we need, since the database was not found; therefore it 
    * is OK to call operationEnd on the existing locker. 
    */ 
    if (!isWritableLocker) { 
     locker.operationEnd(OperationStatus.SUCCESS); 
     locker = LockerFactory.getWritableLocker 
      (this, 
      txn, 
      dbConfig.getTransactional(), 
      true, // retainNonTxnLocks 
      autoTxnIsReplicated, 
      null); 
     isWritableLocker = true; 
    } 

    newDb.initNew(this, locker, databaseName, dbConfig); 
} else { 
    /* We aren't allowed to create this database. */ 
    throw new DatabaseNotFoundException("Database " + 
             databaseName + 
             " not found."); 
} 

에서 그리고 사용자가 설정 한 setAllowCreate은 false입니다. 코드를 살펴 보니 문제가되는 것 같습니다.

+0

데이터베이스가 존재하지 않는 경우에만 allowCreate가 필요하다고 생각했습니다. 답변 해 주셔서 감사합니다. 시도한 다음 동의 할 것입니다. 양해 해 주셔서 감사합니다. –

관련 문제