Forum Discussion
Yes I am able to connect via SQLConnection.
But the situation is i have written groovy code for connection as well as query in same groovy teststep.
And, there is option in Ready APi to make or configure JDBC connection at project level using Databses menu[Refer to attachment]. I want ot use either this configuration in my grrovy script or sql connection made in setup script.
~Shivani
There are two options.
First option - Create a JDBC connection via "databases" and you can build your queries i.e select X from Z where A = 2 etc. Once you are happy with the query, the outcome gets stored in the custom properties automatically and to call that custom property all you have to do is ${DataSourceName#PropertyName}. This is simple and straight forward way for data-driving.
Please find link below to help you.
https://support.smartbear.com/readyapi/docs/testing/data-driven/concepts.html
Second option - Create a JDBC connection via groovy script and store that connection in a custom property and just recall that custom property everytime you want to run the sql connection. You will then write your own custom query and store the query output manually into custom properties.
I personally prefer option one simply because it's easy and less time consuming, though if you have some very complex custom queries that "query builder" cannot support then you could use the second option I suppose.
- ShivaniKamboj7 years agoOccasional Contributor
Thanks for such quick response.
But i am not sure about saving any sql connection object in custom properties so as to reuse it in my scripts in between test steps.
Can you guide me with any such sample example
Thanks
- MoUddin7 years agoContributor
As far as I can tell there is no way to preserve the sql instance or fetch it unfortunately. I have read through the groovy SQL documentation but I didn't see a way to do it.
you can however move your script into a script library I would create a script methods for both opening and for closing connections
Hope this was helpful,
Mo
- ShivaniKamboj7 years agoOccasional Contributor
Yes , this could be solution if this script is having some logic which can be used anywhere in the project, but in case of DB connection I dont think would be of that Use.
Is there any way to use DB confiuration at Project level in Databases Menu in test scripts?
Related Content
- 8 years ago
Recent Discussions
- 23 hours ago
- 17 days ago