2 回答

TA貢獻(xiàn)1820條經(jīng)驗(yàn) 獲得超2個(gè)贊
public class MongoDBJDBC {
public static void main(String[] args) {
try {
// 實(shí)例化Mongo對(duì)象,連接27017端口
Mongo mongo = new Mongo("localhost", 27017);
// 連接名為yourdb的數(shù)據(jù)庫(kù),假如數(shù)據(jù)庫(kù)不存在的話,mongodb會(huì)自動(dòng)建立
DB db = mongo.getDB("test");
// Get collection from MongoDB, database named "yourDB"
// 從Mongodb中獲得名為yourColleection的數(shù)據(jù)集合,如果該數(shù)據(jù)集合不存在,Mongodb會(huì)為其新建立
DBCollection collection = db.getCollection("test1");
// 使用BasicDBObject對(duì)象創(chuàng)建一個(gè)mongodb的document,并給予賦值。
BasicDBObject document = new BasicDBObject();
//document.put("id", 1001);
//document.put("msg", "hello world mongoDB in Java");
// 將新建立的document保存到collection中去
//collection.insert(document);
// 創(chuàng)建要查詢的document

TA貢獻(xiàn)1866條經(jīng)驗(yàn) 獲得超5個(gè)贊
Connection conn = null;
CallableStatement cStmt = null;
PreparedStatement pStmt = null;
ResultSet rs = null;
conn = ConnectionManagerDao.getConn();
//關(guān)鍵代碼
cStmt = conn.prepareCall("{call proc_PagingVie(?,?,?,?,?,?,?,?,?) }");
//call 存儲(chǔ)過(guò)程名(?,?,?)-問(wèn)號(hào)的是參數(shù)
添加回答
舉報(bào)