Posts

MongoDB- Java                                                              In this article, we’ll take a look at integrating MongoDB (a popular NoSQL database) with Java. Prerequisites- You need to make sure that you have MongoDB JDBC driver and Java set up on the machine. Connect to Database To connect database, you need to specify the database name, if the database doesn't exist then MongoDB creates it automatically. import  com.mongodb .client.MongoDatabase ; import  com.mongodb.MongoClient ;   public class Connect {      public static void  main( String   args [] )  {             // Creating a Mongo client       MongoClient  mongo = new  MongoClient ( " localhost" , 27017 );    //Accessing the database       MongoDatabase  database =  mongo.getDatabase (" myDb ");  System.out.println (" Connected ! );         }  } Create a Collection To create a collection,  createCollection ( ) method of com
Recent posts