How to connect to Mongo DB using JDBC step in soap ui.
I have placed driver jar files(mongo-java-driver-3.4.2 and mongodb-driver-3.4.2) in bin/ext.
Below details are given in jdbc step
Connection String: jdbc:mongodb://localhost:27017/Metro-Bank
But I am getting error as below while executing
com.eviware.soapui.support.SoapUIException: Failed to init connection for driver [mongodb.jdbc.MongoDriver], connectionString [jdbc:mongodb://localhost:27017/Metro-Bank]
Please guide me if we can connect to mongoDB using JDBC step in SOAP UI(free version)
Hi @ekta_sriv ,
Not sure about JDBC step but i have did the same using groovy with (mongo-java-driver-3.4.2) driver you can have a look at below code:
String url = "mongodb://USER_NAME:PSWD@PORT/?authSource=AUTH_SOURCE&authMechanism=AUTH_MECHANISM"
MongoClientURI client = new MongoClientURI(url);
MongoClient mongoClient = new MongoClient(client);
DB db = mongoClient.getDB("YOUR DB NAME");
DBCollection collec = db.getCollection("YOUR DB COLLECTION NAME");
BasicDBObject query = new BasicDBObject();
def queryExec = collec.find(query);
//YOUR CODE to fetch values;
Click "Accept as Solution" if my answer has helped,Remember to give "Kudos" 🙂 ↓↓↓↓↓