/**
* 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 {
?
/** 數(shù)據(jù)庫(kù)連接IP */
public static final String DB_HOST ="192.168.35.101";
?
/** 數(shù)據(jù)庫(kù)連接端口 */
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 閱讀(99)
評(píng)論(0) 編輯 收藏