本文整理汇总了Java中com.sequoiadb.base.Sequoiadb类的典型用法代码示例。如果您正苦于以下问题:Java Sequoiadb类的具体用法?Java Sequoiadb怎么用?Java Sequoiadb使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Sequoiadb类属于com.sequoiadb.base包,在下文中一共展示了Sequoiadb类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: queryAll
import com.sequoiadb.base.Sequoiadb; //导入依赖的package包/类
/**
*
* @param dbcollection
* @return
*/
public List<BSONObject> queryAll() {
List<BSONObject> list = new ArrayList<BSONObject>();
DBCursor cursor = null;
Sequoiadb sdb = DbConnectionPool.getConnection();
try {
cursor = getDbCollection(sdb).query();
while (cursor.hasNext()) {
BSONObject record = cursor.getNext();
list.add(record);
}
} catch (BaseException e) {
e.printStackTrace();
} finally {
DbConnectionPool.free(sdb);
}
return list;
}
示例2: query
import com.sequoiadb.base.Sequoiadb; //导入依赖的package包/类
/**
*
* 查询多少条数据
*
* @param matcher
* @param selector
* @param order
* @param skipRows
* @param returnRows
* @return
*/
public List<BSONObject> query(BSONObject matcher, BSONObject selector, BSONObject order, long skipRows,
long returnRows) {
Sequoiadb sdb = DbConnectionPool.getConnection();
List<BSONObject> list = new ArrayList<BSONObject>();
DBCursor cursor = null;
try {
cursor = getDbCollection(sdb).query(matcher, selector, order, null, skipRows, returnRows);
while (cursor.hasNext()) {
BSONObject record = cursor.getNext();
list.add(record);
}
} catch (BaseException e) {
e.printStackTrace();
} finally {
DbConnectionPool.free(sdb);
}
return list;
}
示例3: SequoiaConnection
import com.sequoiadb.base.Sequoiadb; //导入依赖的package包/类
public SequoiaConnection(String url, String db) throws UnknownHostException {
// this.url = url;
this._schema = db;
try {
mc = new Sequoiadb(url, "", "");
} catch (BaseException e) {
throw new IllegalArgumentException("Failed to connect to database: " + url
+ ", error description" + e.getErrorType());
}
}
示例4: queryOne
import com.sequoiadb.base.Sequoiadb; //导入依赖的package包/类
/**
* 查询一条数据
*
* @param matcher
* @param selector
* @param order
* @return
*/
public BSONObject queryOne(BSONObject matcher, BSONObject selector, BSONObject order) {
Sequoiadb sdb = DbConnectionPool.getConnection();
try {
return getDbCollection(sdb).queryOne(matcher, selector, order, null, 0);
} catch (Exception e) {
e.printStackTrace();
} finally {
DbConnectionPool.free(sdb);
}
return null;
}
示例5: updateUsingSetOpreator
import com.sequoiadb.base.Sequoiadb; //导入依赖的package包/类
/**
*
* @param matcher
* @param obj
*/
public void updateUsingSetOpreator(BSONObject matcher, Object obj) {
BSONObject modifier = new BasicBSONObject();
Sequoiadb sdb = DbConnectionPool.getConnection();
try {
modifier.put("$set", BasicBSONObject.typeToBson(obj));
getDbCollection(sdb).update(matcher, modifier, null);
} catch (Exception e) {
e.printStackTrace();
} finally {
DbConnectionPool.free(sdb);
}
}
示例6: updateWithUserDefine
import com.sequoiadb.base.Sequoiadb; //导入依赖的package包/类
/**
*
* @param dbcollection
* @param matcher
* @param record
*/
public void updateWithUserDefine(BSONObject matcher, Object record) {
Sequoiadb sdb = DbConnectionPool.getConnection();
try {
BSONObject modifier = BasicBSONObject.typeToBson(record);
getDbCollection(sdb).update(matcher, modifier, null);
} catch (Exception e) {
e.printStackTrace();
} finally {
DbConnectionPool.free(sdb);
}
}
示例7: updateCounter
import com.sequoiadb.base.Sequoiadb; //导入依赖的package包/类
/**
*
* @param matcher
* @param fieldName
* @param increment
*/
public void updateCounter(BSONObject matcher, String fieldName, int increment) {
Sequoiadb sdb = DbConnectionPool.getConnection();
try {
BSONObject obj = new BasicBSONObject();
BSONObject rule = new BasicBSONObject();
rule.put(fieldName, increment);
obj.put(MatchConst._INC, rule);
getDbCollection(sdb).update(matcher, obj, null);
} catch (BaseException e) {
e.printStackTrace();
} finally {
DbConnectionPool.free(sdb);
}
}
示例8: delete
import com.sequoiadb.base.Sequoiadb; //导入依赖的package包/类
public void delete(BSONObject matcher) {
Sequoiadb sdb = DbConnectionPool.getConnection();
try {
getDbCollection(sdb).delete(matcher);
} catch (BaseException e) {
e.printStackTrace();
} finally {
DbConnectionPool.free(sdb);
}
}
示例9: insert
import com.sequoiadb.base.Sequoiadb; //导入依赖的package包/类
public void insert(Object obj) {
Sequoiadb sdb = DbConnectionPool.getConnection();
if (obj != null) {
try {
BSONObject bson = BasicBSONObject.typeToBson(obj);
getDbCollection(sdb).insert(bson);
} catch (Exception e) {
e.printStackTrace();
} finally {
DbConnectionPool.free(sdb);
}
}
}
示例10: batchInsert
import com.sequoiadb.base.Sequoiadb; //导入依赖的package包/类
/**
*
* @param items
*/
public void batchInsert(List<BSONObject> items) {
Sequoiadb sdb = DbConnectionPool.getConnection();
try {
getDbCollection(sdb).bulkInsert(items, 0);
} catch (Exception e) {
e.printStackTrace();
} finally {
DbConnectionPool.free(sdb);
}
}
示例11: getDbCollection
import com.sequoiadb.base.Sequoiadb; //导入依赖的package包/类
/**
* @param sdb
* @return
*/
private DBCollection getDbCollection(Sequoiadb sdb) {
CollectionSpace db = null;
DBCollection dbCollection = null;
if (sdb.isCollectionSpaceExist(dataSpaceName))
db = sdb.getCollectionSpace(dataSpaceName);
else
db = sdb.createCollectionSpace(dataSpaceName);
if (db.isCollectionExist(dataCollectionName))
dbCollection = db.getCollection(dataCollectionName);
else
dbCollection = db.createCollection(dataCollectionName);
return dbCollection;
}
示例12: getCount
import com.sequoiadb.base.Sequoiadb; //导入依赖的package包/类
public long getCount(BSONObject matcher) {
Sequoiadb sdb = DbConnectionPool.getConnection();
try {
return getDbCollection(sdb).getCount(matcher);
} catch (Exception e) {
e.printStackTrace();
} finally {
DbConnectionPool.free(sdb);
}
return 0;
}
示例13: free
import com.sequoiadb.base.Sequoiadb; //导入依赖的package包/类
public static void free(Sequoiadb sdb) {
if (sdb != null && sdb.isValid())
datasource.close(sdb);
}