Package com.jk.data.datasource
Class JKNoSqlDataSource
java.lang.Object
com.jk.data.datasource.JKNoSqlDataSource
This class is designed to manage connections to a NoSQL
 database, specifically MongoDB.
- Version:
 - 1.0
 - Author:
 - Dr. Jalal H. Kiswani
 
- 
Constructor Summary
ConstructorsConstructorDescriptionThis method constructs a new with default values and sets up theMongoClient.JKNoSqlDataSource(String url, String dbName, String username, String password) This method constructs a new with the provided values and sets up theMongoClient. - 
Method Summary
Modifier and TypeMethodDescriptionvoidclose()This method closes aMongoClientwhen its no longer needed.com.mongodb.client.MongoClientThis method returns theMongoClientinstance.com.mongodb.client.MongoDatabaseThis method returns theMongoDatabaseinstance.protected voidinit()This method initializes theMongoClientby configuring aPojoCodecProviderto handle object mapping, creatingMongoClientSettingswith connection details and credentials, and then creating theMongoClient. 
- 
Constructor Details
- 
JKNoSqlDataSource
public JKNoSqlDataSource()This method constructs a new with default values and sets up theMongoClient. - 
JKNoSqlDataSource
This method constructs a new with the provided values and sets up theMongoClient.- Parameters:
 url- Specifies the MongoDB connection URL.dbName- Specifies the name of the MongoDB database.username- Specifies the user name.password- Specifies the password.
 
 - 
 - 
Method Details
- 
init
protected void init()This method initializes theMongoClientby configuring aPojoCodecProviderto handle object mapping, creatingMongoClientSettingswith connection details and credentials, and then creating theMongoClient. - 
getClient
public com.mongodb.client.MongoClient getClient()This method returns theMongoClientinstance.- Returns:
 - the 
MongoClientinstance. 
 - 
getDatabase
public com.mongodb.client.MongoDatabase getDatabase()This method returns theMongoDatabaseinstance.- Returns:
 - the 
MongoDatabaseinstance. 
 - 
close
public void close()This method closes aMongoClientwhen its no longer needed. 
 -