posts - 495,  comments - 11,  trackbacks - 0
<2011年5月>
24252627282930
1234567
891011121314
15161718192021
22232425262728
2930311234

常用链接

留言簿(1)

随笔档案(496)

搜索

  •  

最新评论

阅读排行榜

评论排行榜

/**
* Java + MongoDB in Secure Mode
*
* @author <a href="mailto:gerald.chen@qq.com">Gerald Chen</a>
* @version $Id: AuthTest.java,v 1.1 2011/05/27 07:24:04 gerald.chen Exp $
*/

public class AuthTest {
 
/** 数据库连接IP */
public static final String DB_HOST ="192.168.35.101";
 
/** 数据库连接端口 */
public static final int DB_PORT =27017;
 
public static void main(String[] args) throws Exception, MongoException {
      Mongo mongo =new Mongo(DB_HOST, DB_PORT);
      DB db = mongo.getDB("test_db");
 
      boolean auth = db.authenticate("gerald", "123456".toCharArray());
      System.out.println(auth);
 
      DBCollection collection = db.getCollection("test_collection");
      System.out.println(collection.getFullName());
 
}
 
}

posted on 2011-05-27 15:42 jadmin 阅读(98) 评论(0)  编辑  收藏

只有注册用户登录后才能发表评论。


网站导航: