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)  編輯  收藏

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


          網站導航:
           
          主站蜘蛛池模板: 开封县| 柳江县| 乌拉特后旗| 集贤县| 黄浦区| 内丘县| 抚顺市| 封丘县| 隆回县| 越西县| 阿合奇县| 霞浦县| 栖霞市| 汤原县| 右玉县| 建瓯市| 焉耆| 孟州市| 布拖县| 临清市| 寻乌县| 徐州市| 六盘水市| 平远县| 枣庄市| 佛坪县| 泰州市| 巴中市| 肃宁县| 滨州市| 新源县| 五寨县| 内乡县| 黑水县| 青海省| 林西县| 大城县| 根河市| 巴林右旗| 成安县| 怀柔区|