Will York
Katalon Apprentice
02/06/2018

MongoDB backend

Does anyone know if there is a way to hook up a MongoDB Database to a test?  I see in the Data Files that I can add a data base, but this seems to only be SQL based.  

I'm going to try to do it through script in the editor, but just wanted to know if there was some built in way to do it first.

Thanks!
Tagged:
Upvote
Quote

Comments

  • Will York
    Katalon Apprentice
    02/28/2018
    No way that I figured out.  I just linked the mongoDB Java driver to the test and everything works just fine
    Upvote
    Quote
  • ChewJin Koh
    Katalon Apprentice
    03/14/2018
    Hi Will York,
    i am starting to read and write to Mongo. Currently i am using SQL db and working fine but i am new on connecting to Mongdb. In here, you seems to have succeeded in doing so, could i request for details on whats needed to coded ? i am using groovy..  TIA
    Upvote
    Quote
  • daniel ryan
    Katalon Apprentice
    04/16/2018
    the tricky bit with mongo is how to find documents that have UUID in them....ive posted how ive manage to do it  here

    https://forum.katalon.com/discussion/6119/how-find-documents-by-uuid-in-a-mongo-database
    Upvote
    Quote
  • daniel ryan
    Katalon Apprentice
    04/16/2018
    ChewJin Koh

    install the mongodb driver and connect to the mongo db through that...something like this

    import com.mongodb.client.MongoCursor
    import com.mongodb.MongoClient
    import com.mongodb.BasicDBObject
    import com.mongodb.DBObject
    import com.mongodb.DBCursor
    import com.mongodb.MongoCredential as MongoCredential
    import com.mongodb.client.MongoCollection
    import com.mongodb.client.MongoDatabase
    import com.mongodb.MongoClientURI
    import com.mongodb.client.result.DeleteResult
    import com.mongodb.client.FindIterable

    public class dataBaseMethods {

    public static Connection connection
    public static MongoDatabase db
    public static MongoClient mongoClient

    def mongoInitialize(String strConnectionString,String Database,String firstCollection){


    mongoClient = null 
    String ClientURI =  strConnectionString
    MongoClientURI uri = new MongoClientURI(ClientURI)
    mongoClient = new MongoClient(uri
    db = mongoClient.getDatabase(Database)
    MongoIterable collections = db.listCollectionNames()
    }
    Upvote
    Quote
Sign In or Register to comment.