/**
* 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 阅读(96)
评论(0) 编辑 收藏