posts - 495,  comments - 11,  trackbacks - 0

          /**
          * 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 閱讀(101) 評論(0)  編輯  收藏

          只有注冊用戶登錄后才能發表評論。


          網站導航:
           
          主站蜘蛛池模板: 康乐县| 阿拉善左旗| 株洲市| 梁河县| 武穴市| 福清市| 理塘县| 西乌珠穆沁旗| 灵丘县| 台北县| 南阳市| 曲阳县| 淮安市| 太仓市| 扶风县| 五原县| 芜湖县| 梧州市| 湛江市| 上饶县| 常熟市| 中超| 汾阳市| 三原县| 蕉岭县| 濮阳县| 浦江县| 塔城市| 临漳县| 云安县| 普陀区| 牟定县| 象州县| 磴口县| 赣州市| 犍为县| 贵南县| 莫力| 东城区| 临海市| 新邵县|