登录 注册
当前位置:主页 > 资源下载 > 44 > mongo-java-driver最新jar.zip下载

mongo-java-driver最新jar.zip下载

  • 更新:2024-10-25 10:28:44
  • 大小:10.53MB
  • 推荐:★★★★★
  • 来源:网友上传分享
  • 类别:MongoDB - 数据库
  • 格式:ZIP

资源介绍

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()); }