![]() ![]() NewDocument.put("name", "mkyong-updated") īasicDBObject updateObj = new BasicDBObject() Update exampleīasicDBObject query = new BasicDBObject() īasicDBObject newDocument = new BasicDBObject() Refer to this Java MongoDB insert example. Save a document (data) into a collection (table) named “user”.ĭBCollection table = db.getCollection("user") īasicDBObject document = new BasicDBObject() MongoClient mongoClient = new MongoClient() ĭB db = mongoClient.getDB("database name") īoolean auth = db.authenticate("username", "password".toCharArray()) If MongoDB in secure mode, authentication is required. MongoClient mongo = new MongoClient( "localhost", 27017 ) Mongo mongo = new Mongo("localhost", 27017) ![]() For MongoDB version >= 2.10.0, uses MongoClient. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. Archives
February 2023
Categories |