mongo-java-driver最新jar.zip

所需积分/C币:46 2020-03-12 13:46:48 10.53MB ZIP
47
收藏 收藏
举报

mongo-java-driver3.0以上jar压缩包大全 try { //1.连接池相关选项配置 MongoClientOptions options=MongoClientOptions.builder() .connectionsPerHost(poolSize) .minConnectionsPerHost(minpoolsize) .maxConnectionIdleTime(maxidletimems) .threadsAllowedToBlockForConnectionMultiplier(blockSize) .maxWaitTime(maxWaitTime) .socketTimeout(socketTimeout) .connectTimeout(connectTimeout) .build(); //2.鉴权配置 MongoCredential credential = MongoCredential.createScramSha1Credential(uname, "admin", pwd.toCharArray()); List credentials = new ArrayList(); credentials.add(credential); //3.mongodb服务器相关配置 List addresses=new ArrayList(); addresses.add(new ServerAddress(host, port)); //4.创建客户实例,获取数据库存储对象。 MongoClient mongoClient = new MongoClient(addresses,credentials, options); morphia.mapPackage("com.lolaage");// 告诉morphia到哪个包下面去找实体类 logger.warn("获取数据库连接对象>>>>>>>>>>>>>>>>>"); ds = morphia.createDatastore(mongoClient, databaseName);// 构建Datastore对象,其中`databaseName`是数据库名称 ds.ensureIndexes();//确保索引生效 //} catch (UnknownHostException e) { // logger.error(e.getMessage()); }

...展开详情
立即下载 低至0.43元/次 身份认证VIP会员低至7折
一个资源只可评论一次,评论内容不能少于5个字
您会向同学/朋友/同事推荐我们的CSDN下载吗?
谢谢参与!您的真实评价是我们改进的动力~
上传资源赚钱or赚积分
最新推荐
mongo-java-driver最新jar.zip 46积分/C币 立即下载
1/0