Connect to z/TPF support for MongoDB on the z/TPF system
To connect to z/TPF support for MongoDB, you must create a MongoClient object. The MongoClient object defines the z/TPF server for MongoDB and the authentication credentials that are used when the remote client connects to the z/TPF server for MongoDB.
To connect to z/TPF server for MongoDB, you can create a ServerAddress object, which is passed as a parameter when you create the MongoClient object. The ServerAddress object defines the IP address or host name of the z/TPF system and specifies the port number that the z/TPF server for MongoDB listens to.
- MongoDB Challenge Response (MONGODB-CR) protocol
You can use the createMongoCRCredential() method to create a MongoCredential instance for the MongoDB Challenge Response protocol.
- PLAIN Simple Authentication and Security Layer (SASL) mechanism
You can use the createPlainCredential() method to create a MongoCredential instance for the PLAIN SASL mechanism.
When the connection is established, a single socket that is used to receive subsequent requests and send corresponding responses is created. Each request that is passed on this socket connection is processed in a new ECB that is started by calling the activate_on_receipt socket function.
MongoCredential credential = MongoCredential.createPlainCredential("mongoUser",
"tpfdf", "mongoPwd".toCharArray());
ServerAddress checkIn=new ServerAddress("ztpf.mydomain.com", 27017);
MongoClient mongoClient = new MongoClient(checkIn, Arrays.asList(credential));