Forum Discussion
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.
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
- MoUddin6 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
- ShivaniKamboj6 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?
- jhanzeb16 years agoFrequent Contributor
Hi,
def dbURL="jdbc:jtds:sqlserver://serverNme;databaseName=DBName;trusted_connection=yes "
def dbUsername = ""
def dbPassword = ""You can store individual components of the connection in custom props, i.e username, pw, db name etc. the whole connection cannot be stored in custom props as one.
If you do want to go via groovy route then easier method would be script library as Mo mentioned.
Related Content
- 4 years agoPUM-Prodat-SQL
- 7 years agoGaleG