Forum Discussion

irfan27dec's avatar
irfan27dec
Regular Visitor
6 years ago

No such property: Sql for class: Script19

Pre-requisite:

I have placed mysql connector jar in soapui lib folder

MySQL database has Persons table with few records

 

I have created Groovy script under a test case, below is the script. When I execute I get following error:

No such property: Sql for class: Script19

Please suggest.

 

 

Groovy script:

 

import groovy.sql.Sql.*


try{
//Create DB Connection

def dbURL = "jdbc:mysql://localhost:3306/testDB"
def dbUser = "root"
def dbPassword = "root"
def driver = "com.mysql.jdbc.Driver"
def dbSQL = Sql.newInstance(dbURL,dbUser,dbPassword,driver)

//Execute Query
def query = "Select * from Persons"
dbSQL.eachRow(query){
//log.info "${it.City}"+"-"+"${it.FirstName}"
log.info "${it.City}"
}

}catch(Exception e){
log.info e.getMessage()
}finally{
//Close Connection
//db.close()
}