本文整理匯總了Java中com.sleepycat.je.DatabaseException類的典型用法代碼示例。如果您正苦於以下問題:Java DatabaseException類的具體用法?Java DatabaseException怎麽用?Java DatabaseException使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
DatabaseException類屬於com.sleepycat.je包,在下文中一共展示了DatabaseException類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: asyncAddItemToSort
import com.sleepycat.je.DatabaseException; //導入依賴的package包/類
public void asyncAddItemToSort(byte tbyData[], int nTotalLength, int nNbRecordRead, boolean bVariableLength)
{
// if only 1 dedicated thread is used for adding an item to sort
m_data.setData(tbyData, 0, nTotalLength);
byte tbyKey[] = m_keyDescription.fillNewKeyBuffer(tbyData, nNbRecordRead, bVariableLength);
m_key.setData(tbyKey);
try
{
m_bdb.put(null, m_key, m_data);
//unlock
}
catch (DatabaseException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
// unlock
}
示例2: asyncAddItemToSortByMultiThreads
import com.sleepycat.je.DatabaseException; //導入依賴的package包/類
public void asyncAddItemToSortByMultiThreads(MultiThreadedSortAddItem multiThreadedSortItem, byte tbyData[])
{
// if more than 1 dedicated thread are used for adding an item to sort
DatabaseEntry data = new DatabaseEntry();
data.setData(tbyData, 0, multiThreadedSortItem.m_nTotalLength);
byte tbyKey[] = m_keyDescription.fillNewKeyBuffer(tbyData, multiThreadedSortItem.m_nNbRecordRead, multiThreadedSortItem.m_bVariableLength);
//Dumper.dump("Record read="+multiThreadedSortItem.m_nNbRecordRead);
//Dumper.dump(tbyKey);
DatabaseEntry key = new DatabaseEntry();
key.setData(tbyKey);
try
{
m_bdb.put(null, key, data);
}
catch (DatabaseException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
m_multiThreadedSortItemCache.disposeItemForReuse(multiThreadedSortItem);
}
示例3: syncGetFirst
import com.sleepycat.je.DatabaseException; //導入依賴的package包/類
public byte [] syncGetFirst()
{
try
{
m_cursor = m_bdb.openCursor(null, null);
OperationStatus status = m_cursor.getFirst(m_key, m_data, LockMode.DEFAULT);
if(status == OperationStatus.SUCCESS)
{
m_nNbRecordExported = 1;
byte tDataWithHeader[] = getDataRead();
return tDataWithHeader;
}
}
catch (DatabaseException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
示例4: syncGetNext
import com.sleepycat.je.DatabaseException; //導入依賴的package包/類
public byte [] syncGetNext()
{
try
{
if(m_cursor != null)
{
OperationStatus status = m_cursor.getNext(m_key, m_data, LockMode.DEFAULT);
if(status == OperationStatus.SUCCESS)
{
m_nNbRecordExported++;
byte tDataWithHeader[] = getDataRead();
return tDataWithHeader;
}
}
}
catch (DatabaseException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
示例5: close
import com.sleepycat.je.DatabaseException; //導入依賴的package包/類
public boolean close()
{
if (m_env != null)
{
try
{
// StatsConfig config = new StatsConfig();
// config.setClear(true);
// System.err.println(m_env.getStats(config));
// Finally, close the environment.
m_env.close();
}
catch(DatabaseException dbe)
{
System.err.println("Error closing MyDbEnv: " + dbe.toString());
return false;
}
}
return true;
}
示例6: inLinks
import com.sleepycat.je.DatabaseException; //導入依賴的package包/類
public String[] inLinks(String URL) throws DatabaseException {
EntityIndex<String, Link> subIndex = inLinkIndex.subIndex(URL);
// System.out.println(subIndex.count());
String[] linkList = new String[(int) subIndex.count()];
int i = 0;
EntityCursor<Link> cursor = subIndex.entities();
try {
for (Link entity : cursor) {
linkList[i++] = entity.fromURL;
// System.out.println(entity.fromURL);
}
} finally {
cursor.close();
}
return linkList;
}
示例7: countKeys
import com.sleepycat.je.DatabaseException; //導入依賴的package包/類
public long countKeys(ValueType value) {
DatabaseEntry keyEntry = new DatabaseEntry(valueConverter.toByteArray(value));
DatabaseEntry valueEntry = new DatabaseEntry();
SecondaryCursor cursor = null;
try {
cursor = secondaryDb.openCursor(txn().getBJETransaction(), cursorConfig);
OperationStatus status = cursor.getSearchKey(keyEntry, valueEntry, dummy, LockMode.DEFAULT);
if (status == OperationStatus.SUCCESS)
return cursor.count();
else
return 0;
}
catch (DatabaseException ex) {
throw new HGException(ex);
}
finally {
if (cursor != null) {
try {
cursor.close();
}
catch (Throwable t) {
}
}
}
}
示例8: getSearchKey
import com.sleepycat.je.DatabaseException; //導入依賴的package包/類
/**
* Moves the cursor to the given key
*/
public void getSearchKey(Integer key) {
try {
DatabaseEntry dbKey = new DatabaseEntry();
integerBinding.objectToEntry(key, dbKey);
if (myCursor.getSearchKey(dbKey, foundData, LockMode.DEFAULT) == OperationStatus.SUCCESS) {
conceptVectorRecord = new ConceptVectorRecord(key);
conceptVectorRecord.setConceptVector((ConceptVector) recordDatabaseBinding.entryToObject(foundData));
}
else {
conceptVectorRecord = null;
}
} catch (DatabaseException e) {
e.printStackTrace();
}
}
示例9: load
import com.sleepycat.je.DatabaseException; //導入依賴的package包/類
/**
* 構造Web圖,從文件內讀入。每一行為一個對應關係,例如 http://url1.com -> http://url2.com 1.0 表示對於鏈接
* http://url1.com所表示的網頁上麵,有一個超鏈接http://url2.com 並且他們之間的權重為1.0
*/
public void load(File file) throws IOException, FileNotFoundException, DatabaseException {
@SuppressWarnings("resource")
BufferedReader reader = new BufferedReader(new FileReader(file));
String line;
while ((line = reader.readLine()) != null) {
int index1 = line.indexOf("->");
if (index1 == -1) {
continue;
} else {
String url1 = line.substring(0, index1).trim();
String url2 = line.substring(index1 + 2).trim();
// Double strength = new Double(1.0);
index1 = url2.indexOf(" ");
if (index1 != -1)
try {
// strength = new
// Double(url2.substring(index1+1).trim());
url2 = url2.substring(0, index1).trim();
} catch (Exception e) {
}
addLink(url1, url2);
}
}
}
示例10: processRecordsToTempStore
import com.sleepycat.je.DatabaseException; //導入依賴的package包/類
private void processRecordsToTempStore(Map<Integer, ConceptToConceptVectorRecordIndexEntry> processedRecordsMap, Database temp, Integer batch, Map<Integer, IntList> batchHistory) {
try {
for (Integer key: processedRecordsMap.keySet()) {
ConceptToConceptVectorRecordIndexEntry addition = processedRecordsMap.get(key);
BatchwiseIntegerID batchwiseConceptID = new BatchwiseIntegerID(key, batch);
DatabaseEntry databaseKey = new DatabaseEntry();
tempkeyBinding.objectToEntry(batchwiseConceptID, databaseKey);
DatabaseEntry databaseValue = new DatabaseEntry();
conceptToRecordIndexEntryBinding.objectToEntry(addition, databaseValue);
temp.put(null, databaseKey, databaseValue);
IntList batchArray = batchHistory.get(key);
if (batchArray == null) {
batchArray = new IntList();
batchHistory.put(key, batchArray);
}
batchArray.add(batch);
}
} catch (DatabaseException e) {
e.printStackTrace();
}
}
示例11: next
import com.sleepycat.je.DatabaseException; //導入依賴的package包/類
public void next() {
try {
if (myCursor.getNext(foundKey, foundData, LockMode.DEFAULT) == OperationStatus.SUCCESS) {
Integer key = (Integer) integerBinding.entryToObject(foundKey);
conceptVectorRecord = new ConceptVectorRecord(key);
conceptVectorRecord.setConceptVector((ConceptVector) recordDatabaseBinding.entryToObject(foundData));
}
else {
close();
conceptVectorRecord = null;
}
} catch (DatabaseException e) {
e.printStackTrace();
}
}
示例12: clearIndex
import com.sleepycat.je.DatabaseException; //導入依賴的package包/類
public void clearIndex() {
// be careful! you have to rebuild your index EXPLICITELY if your
// recordstore hasn't been cleared as well.
try {
conceptToConceptVectorIndexStore.close();
//Transaction transaction = environment.beginTransaction(null, null);
environment.truncateDatabase(null, dbName, false);
//transaction.commit();
openDB();
index.clear();
} catch (DatabaseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
示例13: processToTempStore
import com.sleepycat.je.DatabaseException; //導入依賴的package包/類
private void processToTempStore(SortedListMap<Integer, SortedIntList2IntMap> coocMap, Database temp, Integer batch, Map<Integer, IntList> batchHistory) {
try {
Iterator<SortedListMap<Integer, SortedIntList2IntMap>.MapEntry<Integer,SortedIntList2IntMap>> entryIt = coocMap.entryIterator();
while (entryIt.hasNext()) {
SortedListMap<Integer, SortedIntList2IntMap>.MapEntry<Integer,SortedIntList2IntMap> entry = entryIt.next();
Integer key = entry.getKey();
BatchwiseIntegerID batchwiseConceptID = new BatchwiseIntegerID(key, batch);
DatabaseEntry databaseKey = new DatabaseEntry();
tempkeyBinding.objectToEntry(batchwiseConceptID, databaseKey);
DatabaseEntry databaseValue = new DatabaseEntry();
myDataBinding.objectToEntry(entry.getValue(), databaseValue);
temp.put(null, databaseKey, databaseValue);
IntList batchArray = batchHistory.get(key);
if (batchArray == null) {
batchArray = new IntList();
batchHistory.put(key, batchArray);
}
batchArray.add(batch);
}
} catch (DatabaseException e) {
e.printStackTrace();
}
}
示例14: tryLock
import com.sleepycat.je.DatabaseException; //導入依賴的package包/類
public synchronized boolean tryLock() {
try {
if (readCount.get() == 0) {
// lock = getEnv().getLock(getLockerId(), true, objectId, LockRequestMode.READ);
}
if (lock != null) {
readCount.set(readCount.get() + 1);
return true;
}
else {
return false;
}
}
catch (LockNotAvailableException le) {
return false;
}
catch (DatabaseException ex) {
throw new HGException(ex);
}
}
示例15: getEntryFromStoreWithID
import com.sleepycat.je.DatabaseException; //導入依賴的package包/類
@Override
protected ConceptToConceptVectorRecordIndexEntry getEntryFromStoreWithID(Integer id) {
ConceptToConceptVectorRecordIndexEntry conceptToRecordIndexEntry = null;
try {
DatabaseEntry databaseKey = new DatabaseEntry();
DatabaseEntry databaseValue = new DatabaseEntry();
myIntegerBinding.objectToEntry(id, databaseKey);
conceptToConceptVectorIndexStore.get(null, databaseKey, databaseValue, LockMode.DEFAULT);
if (databaseValue.getSize() != 0) {
conceptToRecordIndexEntry = (ConceptToConceptVectorRecordIndexEntry) myDataBinding.entryToObject(databaseValue);
}
} catch (DatabaseException e) {
e.printStackTrace();
}
return conceptToRecordIndexEntry;
}