`
- 浏览:
59993 次
- 性别:
- 来自:
银川
-
- package com.eviac.blog.mongo;
- import java.net.UnknownHostException;
- import com.mongodb.BasicDBObject;
- import com.mongodb.DB;
- import com.mongodb.DBCollection;
- import com.mongodb.DBCursor;
- import com.mongodb.Mongo;
- import com.mongodb.MongoException;
- public class MongoDBClient {
- public static void main(String[] args) {
- try {
-
Mongo mongo = new Mongo("localhost", 27017);
-
DB db = mongo.getDB("company");
-
DBCollection collection = db.getCollection("employees");
-
BasicDBObject employee = new BasicDBObject();
- employee.put("name", "Hannah");
- employee.put("no", 2);
- collection.insert(employee);
-
BasicDBObject searchEmployee = new BasicDBObject();
- searchEmployee.put("no", 2);
-
DBCursor cursor = collection.find(searchEmployee);
- while (cursor.hasNext()) {
- System.out.println(cursor.next());
- }
- System.out.println("The Search Query has Executed!");
- } catch (UnknownHostException e) {
- e.printStackTrace();
- } catch (MongoException e) {
- e.printStackTrace();
- }
- }
- }
分享到:
Global site tag (gtag.js) - Google Analytics
相关推荐
Spring Data for MongoDB提供了很多特性,它使很多MongoDB的Java开发者解放了很多。MongoTemplate helper类支持通用的Mongo操作。它整合了文档和POJO之间的对象映射。通常,他会转换数据库访问异常到Spring中的异常...
MongoDB for Java Developers Design, build, and deliver efficient Java applications using the most advanced NoSQL database
MongoMongo努力为Java开发者提供类似于ActiveORM 或者 Hibernate的操作API,并且保留了MongoDB的schemaless、document-based 设计、动态查询、原子修改操作等特性。当然你可以很方便的绕开MongoMongo而使用Java ...
mongodb driver java 源码 2.5.3 版本
本篇文章现在我们就用Java来操作MongoDB的数据。小编觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随小编过来看看吧
mongodb for java api 英文版
一款管理Mongdb的可视化工具,下载后轻松连接,操作简单实用。
解决连接池不够的问题,多连接的问题。适用于mongoDB项目开发,感兴趣可以下载使用,记得好评哦。欢迎在下方留言
MongoDB for Java Developers的随书阅读代码,记录了整本书的大部分案例代码,下载即可运行!
You will then be taken through the Kettle Thin JDBC Driver for enabling a Java application to interact with a database. This will be followed by exploration of a MongoDB collection using Pentaho ...
NULL 博文链接:https://chenhua-1984.iteye.com/blog/2114596
MongoDB Async Java Driver Documentation Welcome to the MongoDB Async Java driver documentation hub. Getting Started The Getting Started guide contains installation instructions and a simple ...
面向字节_MongoDB.pdf
The NoSQL movement is growing in relevance, attracting more and more developers....By the end of this book, you will know everything you need to integrate MongoDB in your Java applications
MongoDB Driver for JAVA 2.5.3 API chm版本
MongoDB React流 Java 驱动程序MongoDB Reactive Streams Java Driver 的开发已移至模块。 Mongo Java 驱动程序的实现。 [ ] ( ) |文献资料所有主要版本的文档都可以在支持/反馈有关 MongoDB Java 驱动程序的问题、...
mongoMorphiaDemo mongoDB 上 morphia 演示的简单演示——这是“Java for MongoDB”课程的演示代码: : 该演示将展示如何使用开源项目将 java 对象插入/更新到 MongoDB: Morphia(Morphia 项目: : ) 项目模型:...
With this authoritative introduction, you’ll learn the many advantages of using document-oriented databases, and discover why MongoDB is a reliable, high-performance system that allows for almost ...
编码katas-mongodb-java 用 Java 解决的“Coding Katas for MongoDB”一书的解决方案