当前位置: 首页 > news >正文

免费网站站长推广河北沧州市网络公司

免费网站站长推广,河北沧州市网络公司,有好的学网站建设的书吗,湛江房产信息网#xff08;MongoClient类的实例是#xff09;一个带有内部连接池的MongoDB客户端。对绝大部分应用来说#xff0c;都应该有一个MongoClient实例#xff08;不知怎翻译#xff09;。 下面各种创建实例的方法是等效的#xff0c;并且全部都通过默认端口连到本地数据库的MongoClient类的实例是一个带有内部连接池的MongoDB客户端。对绝大部分应用来说都应该有一个MongoClient实例不知怎翻译。 下面各种创建实例的方法是等效的并且全部都通过默认端口连到本地数据库的 MongoClient mongoClient1 new MongoClient(); MongoClient mongoClient1 new MongoClient(“localhost”); MongoClient mongoClient2 new MongoClient(“localhost”, 27017); MongoClient mongoClient4 new MongoClient(new ServerAddress(“localhost”)); MongoClient mongoClient5 new MongoClient(new ServerAddress(“localhost”), new MongoClientOptions.Builder().build()); 你也可以连接到备份服务器集合通过传递一个备份服务器地址列表作为参数到MongoClient的构造方法中。例如 MongoClient mongoClient new MongoClient(Arrays.asList( new ServerAddress(“localhost”, 27017), new ServerAddress(“localhost”, 27018), new ServerAddress(“localhost”, 27019))); 你还可以使用同样的构造方法连接到分片集群上。 MongoClient会自动检测这些数据库服务器是备份服务器还是集群服务器。 默认情况下所有读写操作都发生在主数据库上但也可以改变读的设置让读操作发生在从数据库 mongoClient.setReadPreference(ReadPreference.secondaryPreferred()); 默认情况下所有写操作都会等待服务器的响应默认的写关注的是WriteConcern.ACKNOWLEDGED 提示MongoClient类取代了Mongo类。同时它也继承自Mongo类但不同的是它所有的写操作默认都是等待服务器响应。另外它的构造方法接受MongoClientOptions和 MongoClientURI类的实例这两者的默认写关注也是一样的。 通常来说使用这个类只要使用MongoClientOptions提供的默认值就行了。特别注意一下每个服务器默认的连接数已经从过去使用Mongo的10增加到了100. A MongoDB client with internal connection pooling. For most applications, you should have one MongoClient instance for the entire JVM. The following are equivalent, and all connect to the local database running on the default port: MongoClient mongoClient1 new MongoClient(); MongoClient mongoClient1 new MongoClient(“localhost”); MongoClient mongoClient2 new MongoClient(“localhost”, 27017); MongoClient mongoClient4 new MongoClient(new ServerAddress(“localhost”)); MongoClient mongoClient5 new MongoClient(new ServerAddress(“localhost”), new MongoClientOptions.Builder().build()); You can connect to a replica set using the Java driver by passing a ServerAddress list to the MongoClient constructor. For example: MongoClient mongoClient new MongoClient(Arrays.asList( new ServerAddress(“localhost”, 27017), new ServerAddress(“localhost”, 27018), new ServerAddress(“localhost”, 27019))); By default, all read and write operations will be made on the primary, but it’s possible to read from secondaries by changing the read preference: mongoClient.setReadPreference(ReadPreference.secondaryPreferred()); By default, all write operations will wait for acknowledgment by the server, as the default write concern is WriteConcern.ACKNOWLEDGED. Note: This class supersedes the Mongo class. While it extends Mongo, it differs from it in that the default write concern is to wait for acknowledgment from the server of all write operations. In addition, its constructors accept instances of MongoClientOptions and MongoClientURI, which both also set the same default write concern. In general, users of this class will pick up all of the default options specified in MongoClientOptions. In particular, note that the default value of the connectionsPerHost option has been increased to 100 from the old default value of 10 used by the superseded Mongo class. Since:2.10.0See Also:ReadPreference.primary()com.mongodb.WriteConcern.ACKNOWLEDGEDMongoClientOptionsMongoClientURI
http://www.yutouwan.com/news/107967/

相关文章:

  • 做电影网站要买什么淘客做自己的网站
  • 央企网站开发大鹏新区住房和建设局网站
  • 企业网站推广方式和策略雄安新区网站建设公司
  • 公司网站建设的签订合同注册网站的免费网址是什么
  • 教做粥的网站少儿编程加盟培宝未来
  • 南京专业做网站的公司哪家好做网站学完html
  • 建设一个营销网站有哪些步骤苏州网页设计多少钱
  • 临桂住房和城乡建设局网站做搜索网站挣钱
  • 物联网技术有哪些网站优化定做
  • 深圳网站公司建设方案百度手机助手官网下载
  • 营销网站的优势是什么企业名录搜索软件有哪些
  • 网站建设吧旺道网站优化
  • 网站策划书包括哪些内容长沙网络推广平台
  • 网站数据怎么备份道滘镇网站建设公司
  • 营销型网站建设策划案760关键词排名查询
  • asp.net 跳转别的网站上海抖音推广公司
  • 网站开发公司起名大淘客网站怎么做
  • 襄阳作风建设年网站做企业门户网站
  • 如何借用别人静态网站做模板智能家居产品设计案例
  • 河南网站建设企业网站前端设计是什么
  • 网站建设首先要学会什么asp.net网站项目建设
  • 合肥高端网站建设工作室专业制作网站公司哪家好
  • 哪些网站建设公司深圳最出名的50家公司
  • 影响力网站建设手机网站做多少钱
  • 上海自助建站企业软件开发工具自考
  • 航天基地规划建设局网站深圳图派做的网站后台加什么
  • 保定做网站做网站怎么开后台
  • 物流运输 有哪些网站可以做推广wordpress在线考试插件
  • 河源市做网站站长工具麻豆
  • 山东省建设八大员考试网站嘉兴百度网站推广