Related Materials
1. MongoDB for Java driver package
Https://github.com/mongodb/mongo-java-driver/downloads
2,Online document
Http://www.mongodb.org/display/DOCS/Java+Language+Center
Operation
1. query all data in a table (ca
Related reading:
Install and start MongoDB in Linux
Advanced query example in MongoDB
MongoDB Java API for insert and single collection basic query examples
Query operations under
This example for you to share the Java Operation MongoDB Fuzzy query and paging query for your reference, the specific contents are as follows
Fuzzy query conditions:1. Perfect MatchPattern pattern = pattern.compile ("^name$", pattern.case_insensitive);2, right matchingPatt
ObjectiveMongoDB Java Driver provides the function of query, query condition is also Bson object, this article looks at how to carry on the simple data query1. Data structureCollection: FirstcollectionData content:{"_id": ObjectId ("55adba52fa1f3cf038c2aea6"), "name": "User0", "Age": $, "Sex": 0}{"_id": ObjectId ("55adba52fa1f3cf038c2aea7"), "name": "User1", "age
Previous Article: getting started with MongoDB
Http://blog.csdn.net/rjfxd/article/details/12108909
I. Preparations
1. Create a maven project and add the required Dependencies
Of course, you can also create a java project, download and copy the jar file to lib.
2. Enable the mongo service and create a test class for testing.
Ii. complete source code is as follows:
Package com. shxt. mongo; import java.net.
1. Download the driver https://github.com/mongodb/developer-java-driver/downloadsand import it to Java.
2. Create a test code
Import java.net. unknownhostexception;Import java. util. Set;
Import com. MongoDB. basicdbobject;Import com. Mo
Label:Objective In the previous "Java MongoDB query (a) simple query" We have a simple look at the following query, but only those queries are not enough, but also need complex queries, this is described in this article. 1. Data structure Collection: Firstcollection Data con
Conditions similar to: a=5 or (a=2 and b>3)Basicdblist endlist = new Basicdblist ();Basicdbobject forceend = new Basicdbobject ();Forceend.put ("status", 5);Basicdblist condlist = new Basicdblist ();Basicdbobject autoend = new Basicdbobject ();Condlist.add (New Basicdbobject ("status", 2));Condlist.add (New Basicdbobject ("EndTime", New Basicdbobject ("$lt", New Date ()));Autoend.put ("$and", condlist);Endlist.add (Forceend);Endlist.add (Autoend);Basicdbobject.put ("$or", endlist);A compound
Look for a long time query Objectid method is wrong, with Mongovue can query out, but is using Java do not know how to query
1.mongovue Query mode:
Copy Code code as follows:
{"_id": ObjectId ("5326bfc0e6f780b21635248f")}
2. In the pure
()) {User user = new user ();
User.parse (Find.next ());
SYSTEM.OUT.PRINTLN (user); }} public static void Main (string[] ArGS) {Userdao Userdao = new Userdao ();
Userdao.query (); }
Queryoperators class source code:
Queryoperators.java/** * Copyright (C) 10gen Inc.
* Licensed under the Apache License, Version 2.0 (the "License");
* You could not use this file, except in compliance with the License. * Obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * *
Label:The 3.x version of MongoDB's Java driver has a completely new design compared to 2.x, and there is a big difference between class libraries and usage methods. For example, replacing basicdbobject with document, using builders class to build Bson instead of direct input $ command and so on, this paper deals with the use of the common additions and deletions based on the 3.2 version. In order to avoid lengthy space, divided into additions and dele
Learning MongoDB 5: MongoDB query (array, embedded documentation) (2), mongodb embedded1. Introduction We introduced db in the previous article. collection. find () can be used to query conditions and specify fields returned by using the projection operator to omit this para
MongoDB Practice Notes for beginners-install, create databases, save and query data, and learn mongodb
MongoDB is a scalable and High-Performance Distributed Document storage database written in C. It is designed to provide scalable and high-performance data storage solutions for web applications. It features high perf
Different query operators in MongoDB treat null values differently.The examples on this page with the Db.collection.find () method in the MONGO shell. To populate the users collection referenced in the examples, run the following in MONGO Shell:Db.users.insert ( [ {"_id":, "name": null}, {"_id": 901} ])Equality FilterThe {name:null} query matches do
Lesson 5 MongoDB Data Query (II): mongodb Data Query1. Course outlineThis course continues to explain MongoDB Data Query related content, including MongoDB cursor, fuzzy query, and use
Learning MongoDB 6: MongoDB query (cursor operation, cursor information) (3), mongodb cursorI. Introduction
Db. collection. find () can be used to query based on conditions and specify fields returned using the projection operator to omit this parameter to return all fields
Lesson 4 MongoDB Data Query (1): mongodb Data Query1. Course outlineThis course mainly describes MongoDB Data Query related content, including the introduction and use of the find function, query operator introduction and use, emb
),//Query the Name property New Basicdbobject ("Age", true),//Sort by age False,//Whether Delete, true means delete New Basicdbobject ("name", "ABC"),//modified value, change name to ABC true)); Queryall ();}MongoDB does not support federated queries, subqueries, which need to be done by ourselves in the program. The result set of the
field, and just the bo NUS field in the documents in the points array. The _id field is returned by default.Db.users.find ({status: "A"}, {name:1, status:1, "Points.bonus": 1})The operation returns the following documents:{"_id": 2, "name": "Bob", "status": "A", "points": [{"Bonus": $}, {"Bonus": 12}]} {"_id": 3, "name": "Ahn", "status": "A", "points": [{"Bonus": 8}, {"Bonus": 20}]} {"_id": 6, "name": "abc", "Status": "A", "points": [{"Bonus": 8}, {"Bonus": 7}]}Project specific array Elements i
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.