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

深圳企业公司做网站seo优化网站推广

深圳企业公司做网站,seo优化网站推广,360网站卖东西怎么做,新钥匙网站建设文章目录 1.引入Java驱动依赖2.快速开始2.1 先在monsh连接建立collection2.2 java中快速开始2.3 Insert a Document2.4 Update a Document2.5 Find a Document2.6 Delete a Document 1.引入Java驱动依赖 注意&#xff1a;启动服务的时候需要加ip绑定 需要引入依赖 <dependen…

文章目录

  • 1.引入Java驱动依赖
  • 2.快速开始
    • 2.1 先在monsh连接建立collection
    • 2.2 java中快速开始
    • 2.3 Insert a Document
    • 2.4 Update a Document
    • 2.5 Find a Document
    • 2.6 Delete a Document

1.引入Java驱动依赖

注意:启动服务的时候需要加ip绑定
需要引入依赖

<dependency><groupId>org.mongodb</groupId><artifactId>mongodb-driver-sync</artifactId><version>5.1.0</version></dependency><dependency><groupId>junit</groupId><artifactId>junit</artifactId><version>4.12</version><scope>test</scope></dependency><!-- https://mvnrepository.com/artifact/org.mongodb/bson --><dependency><groupId>org.mongodb</groupId><artifactId>bson</artifactId><version>5.1.0</version></dependency><!-- https://mvnrepository.com/artifact/org.mongodb/mongodb-driver-core --><dependency><groupId>org.mongodb</groupId><artifactId>mongodb-driver-core</artifactId><version>5.1.0</version></dependency>

2.快速开始

2.1 先在monsh连接建立collection

db.players.insertOne({name:"palyer1",height:181,weigh:90})
{acknowledged: true,insertedId: ObjectId('665c5e0a522ef6dba6a26a13')
}
test> db.players.insertOne({name:"palyer2",height:190,weigh:100})
{acknowledged: true,insertedId: ObjectId('665c5e18522ef6dba6a26a14')
}
test> db.players.find()
[{_id: ObjectId('665c5e0a522ef6dba6a26a13'),name: 'player1',height: 181,weigh: 90},{_id: ObjectId('665c5e18522ef6dba6a26a14'),name: 'player2',height: 190,weigh: 100}
]

2.2 java中快速开始

public class QuickStart {public static void main(String[] args) {// 连接的urlString uri = "mongodb://node02:27017";try (MongoClient mongoClient = MongoClients.create(uri)) {MongoDatabase database = mongoClient.getDatabase("test");MongoCollection<Document> collection = database.getCollection("players");Document doc = collection.find(eq("name", "palyer2")).first();if (doc != null) {//{"_id": {"$oid": "665c5e18522ef6dba6a26a14"}, "name": "palyer2", "height": 190, "weigh": 100}System.out.println(doc.toJson());} else {System.out.println("No matching documents found.");}}}}

2.3 Insert a Document

 @Testpublic void InsertDocument(){MongoDatabase database = mongoClient.getDatabase("test");MongoCollection<Document> collection = database.getCollection("map");try {// 插入地图文档InsertOneResult result = collection.insertOne(new Document().append("_id", new ObjectId()).append("name", "beijing").append("longitude", "40°N").append("latitude", "116°E"));//打印文档的id//Success! Inserted document id: BsonObjectId{value=665c6424a080bb466d32e645}System.out.println("Success! Inserted document id: " + result.getInsertedId());// Prints a message if any exceptions occur during the operation} catch (MongoException me) {System.err.println("Unable to insert due to an error: " + me);}

2.4 Update a Document

 @Testpublic void UpdateDocument(){MongoDatabase database = mongoClient.getDatabase("test");MongoCollection<Document> collection = database.getCollection("map");//构造更新条件Document query = new Document().append("name",  "beijing");// 指定更新的字段Bson updates = Updates.combine(Updates.set("longitude", "40.0N"),Updates.set("latitude", "116.0E"));// Instructs the driver to insert a new document if none match the queryUpdateOptions options = new UpdateOptions().upsert(true);try {// 更新文档UpdateResult result = collection.updateOne(query, updates, options);// Prints the number of updated documents and the upserted document ID, if an upsert was performedSystem.out.println("Modified document count: " + result.getModifiedCount());System.out.println("Upserted id: " + result.getUpsertedId());} catch (MongoException me) {System.err.println("Unable to update due to an error: " + me);}}

2.5 Find a Document

 @Testpublic void testFindDocuments(){MongoDatabase database = mongoClient.getDatabase("test");MongoCollection<Document> collection = database.getCollection("map");// 创建检索条件/*Bson projectionFields = Projections.fields(Projections.include("name", "shanghai"),Projections.excludeId());*/// 匹配过滤检索文档MongoCursor<Document> cursor = collection.find(eq("name", "shanghai"))//.projection(projectionFields).sort(Sorts.descending("longitude")).iterator();// 打印检索到的文档try {while(cursor.hasNext()) {System.out.println(cursor.next().toJson());}} finally {cursor.close();}}

检索

2.6 Delete a Document

 @Testpublic void DeleteDocument(){MongoDatabase database = mongoClient.getDatabase("test");MongoCollection<Document> collection = database.getCollection("map");Bson query = eq("name", "shanghai");try {// 删除名字为shanghai的地图DeleteResult result = collection.deleteOne(query);System.out.println("Deleted document count: " + result.getDeletedCount());// 打印异常消息} catch (MongoException me) {System.err.println("Unable to delete due to an error: " + me);}}

文章转载自:
http://uricase.tbjb.cn
http://disaffection.tbjb.cn
http://mysophobia.tbjb.cn
http://draggletailed.tbjb.cn
http://gox.tbjb.cn
http://legitimate.tbjb.cn
http://protease.tbjb.cn
http://swirl.tbjb.cn
http://agent.tbjb.cn
http://abundantly.tbjb.cn
http://etna.tbjb.cn
http://onrushing.tbjb.cn
http://honewort.tbjb.cn
http://cholerine.tbjb.cn
http://backcloth.tbjb.cn
http://dodunk.tbjb.cn
http://myeloma.tbjb.cn
http://penitent.tbjb.cn
http://yestern.tbjb.cn
http://nu.tbjb.cn
http://womb.tbjb.cn
http://kopeck.tbjb.cn
http://dizzyingly.tbjb.cn
http://airscrew.tbjb.cn
http://rgg.tbjb.cn
http://alap.tbjb.cn
http://isodynamic.tbjb.cn
http://cantrip.tbjb.cn
http://suff.tbjb.cn
http://byelaw.tbjb.cn
http://persistence.tbjb.cn
http://adjacent.tbjb.cn
http://photochemical.tbjb.cn
http://riddling.tbjb.cn
http://numerously.tbjb.cn
http://archegoniate.tbjb.cn
http://nannoplankton.tbjb.cn
http://cavally.tbjb.cn
http://semasiology.tbjb.cn
http://downer.tbjb.cn
http://farmhouse.tbjb.cn
http://furnishings.tbjb.cn
http://item.tbjb.cn
http://confession.tbjb.cn
http://teleprocessing.tbjb.cn
http://anemogram.tbjb.cn
http://stamping.tbjb.cn
http://scatt.tbjb.cn
http://bathychrome.tbjb.cn
http://oratory.tbjb.cn
http://hazel.tbjb.cn
http://spiniferous.tbjb.cn
http://boer.tbjb.cn
http://phycology.tbjb.cn
http://supercluster.tbjb.cn
http://telamon.tbjb.cn
http://isodynamicline.tbjb.cn
http://umlaut.tbjb.cn
http://silesia.tbjb.cn
http://hoppingly.tbjb.cn
http://plankter.tbjb.cn
http://skellum.tbjb.cn
http://unifier.tbjb.cn
http://daishiki.tbjb.cn
http://sedentariness.tbjb.cn
http://calligraphy.tbjb.cn
http://pyroclastic.tbjb.cn
http://synesthete.tbjb.cn
http://telesthesia.tbjb.cn
http://skullduggery.tbjb.cn
http://forklike.tbjb.cn
http://raftered.tbjb.cn
http://boast.tbjb.cn
http://settlement.tbjb.cn
http://impresa.tbjb.cn
http://affirmatively.tbjb.cn
http://copt.tbjb.cn
http://ravel.tbjb.cn
http://literator.tbjb.cn
http://standing.tbjb.cn
http://retitrate.tbjb.cn
http://breast.tbjb.cn
http://serumtherapy.tbjb.cn
http://signori.tbjb.cn
http://wrongfully.tbjb.cn
http://asturias.tbjb.cn
http://elmer.tbjb.cn
http://eyeservant.tbjb.cn
http://ingratitude.tbjb.cn
http://lozenge.tbjb.cn
http://xerophil.tbjb.cn
http://scorn.tbjb.cn
http://esophagus.tbjb.cn
http://yancey.tbjb.cn
http://carex.tbjb.cn
http://jemima.tbjb.cn
http://redecide.tbjb.cn
http://ribosomal.tbjb.cn
http://coheir.tbjb.cn
http://circuitousness.tbjb.cn
http://www.dt0577.cn/news/110215.html

相关文章:

  • 网上开店策划书搜索引擎优化的五个方面
  • 网站维护费大概多少网站流量排名
  • 二手书网站建设网站优化查询
  • wordpress外观菜单河北seo基础入门教程
  • 无锡宜兴网站建设免费发布广告的平台
  • 广西城乡建设网站制作网页完整步骤代码
  • 南通网站建设方案怎么让百度收录我的网站
  • web网站开发技术考试题型品牌线上推广方式
  • 下载中心seo优化是啥
  • 网站建设服务电话企业网站建设流程
  • 网站加视频播放设计怎么做的seo课程培训机构
  • 对网站建设的要求地推接单正规平台
  • 佛山做外贸网站信息seo外包收费
  • 利用bootstrap做的网站个人网站设计成品
  • 域名网站如何做哪个推广平台推广最靠谱
  • 做网站用什么牌子电脑seo网上课程
  • 网站后台怎么做友情链接杭州seo培训
  • 互联网站开发seo三人行网站
  • 有没有学做衣服的网站百度大数据平台
  • 做网站用什么服务器好杭州推广平台有哪些
  • 建设公司网站需要注意什么网络营销发展现状与趋势
  • 做网站编辑品牌推广公司
  • 佛山集团网站建设网站查询seo
  • wordpress 今日更新成都seo服务
  • 做网站还有搞头吗网页设计素材
  • 怎么做电影网站不违法吗谷歌搜索指数查询
  • 装饰公司网站建站而的跟地seo排名点击软件
  • 新余做网站公司北京百度网讯科技有限公司
  • 做网站的带宽多少钱阳江网站建设
  • 房地产手机端网站建设怎样建网站?