Ask a Question

Groovy SQL.execute help

Super Contributor

Groovy SQL.execute help

I have script which have a groovy script which updates information in the database. they look something like this

import groovy.sql.Sql

//Retreive email value
def emailStep = testRunner.testCase.getTestStepByName( "Properties" )
Email = emailStep.getPropertyValue( "Email" )

//update database to lock account
sql = Sql.newInstance("jdbc:sqlserver://:1433;databaseName=;user=;password=;")


These script were working fine. I tested the sql statement using groovyconsole and verified against the database if the update worked. However, this morning when I ran the scripts I received the following error and I cannot figure out what is wrong.

Thu May 31 10:57:17 PDT 2007:ERROR:java.sql.SQLException: No suitable driver

I checked the JavaHome\lib\ext and soapui\jre\lib\ext and they have the 'sqljdbc.jar file in them.



Entirely my fault.

Add the following line before the line

driver = Class.forName("").newInstance();


You see, the reason it worked yesterday was because Groovy had already loaded the driver into memory and didn't clean it up. This of course happened when you shut down soapUI for the day.

What was needed was a new line of code for loading the driver.

Product Guy for Ready! API, SoapUI and all things API
Showing results for 
Search instead for 
Did you mean: