Package util

Class Connection

java.lang.Object
util.Connection

public class Connection extends Object
  • Constructor Details

    • Connection

      public Connection()
  • Method Details

    • initConnection

      public static void initConnection(String ip, int port, String databaseName, String username, String password)
      This method creates the connection to the MongoDB container and databases.
      Parameters:
      ip - IP where MongoDB is available. [MANDATORY]
      port - PORT where the MongoDB services are available. [MANDATORY]
      databaseName - DATABASE name where all the operations are going to be performed. [MANDATORY]
      username - Credentials when MongoDB requires them. [OPTIONAL]
      password - Credentials when MongoDB requires them. [OPTIONAL]
    • getMongoClient

      public static com.mongodb.client.MongoClient getMongoClient()
    • getMongoDatabase

      public static com.mongodb.client.MongoDatabase getMongoDatabase()
    • closeConnection

      public static void closeConnection()
      This method closes the previously created connection to the MongoDB container and databases (if any).