Forum Discussion
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
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.
- MoUddin6 years agoContributor
Is there any way to use DB confiuration at Project level in Databases Menu in test scripts?
No, unfortunately not. Custom properties (the way to preserve values) only store strings. As I said in my previous reply it doesn't seem like there is any way to fetch an existing sql instance.
Instead you will need to open and close the sql instance each time you need to access the database (hence the script library would come in handy to not have to write out the connection parameters each time)
- Olga_T6 years agoSmartBear Alumni (Retired)
Hi all,
ShivaniKamboj, have you found an answer to your question? If so, could you please accept the appropriate answer as a solution? This way, other users can easily find it if they face a similar issue in the future.
Or, do you have any updates or additional details here?
jhanzeb1, MoUddin, thank you for your time looking into the case, it's great to have you both in the Community!
Have a nice day,
Related Content
- 4 years agoPUM-Prodat-SQL
- 3 years agoTCYKPB