DataBase Connection in SetUp script and use the same in Groovy Test Step
Hi All,
I am currently stuck in an issue where i want to configure JDBC connection either in SetUp Script or the one configured at project level 'DataBases' menu and could use the same sql instance in any of the teststep mostly groovy test step while hitting sql query in it.
Here i am trying , but not working:
import groovy.sql.Sql
import com.eviware.soapui.support.GroovyUtils
def dbURL="jdbc:jtds:sqlserver://serverNme;databaseName=DBName;trusted_connection=yes "
def dbUsername = ""
def dbPassword = ""
def dbDriver = "net.sourceforge.jtds.jdbc.Driver"
def sql = Sql.newInstance(dbURL,dbDriver)
context.setProperty("DBCon", sql)
Using this sql instance in my teststep(Groovy) as:
import groovy.sql.Sql
import com.eviware.soapui.support.GroovyUtils
def sqlObj=context.getProperty("DBCon")
def connection = sqlObj.firstRow("SELECT * FROM Table ")
log.info connection
Thanks!!
~Shivani