cancel
Showing results for 
Search instead for 
Did you mean: 

Groovy SQL.execute help

Super Contributor

Groovy SQL.execute help

hello,
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=;")
sql.execute()

------------------------------------------------------------------------------

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.

Thanks

Ali
1 REPLY 1
Highlighted

Re: Groovy SQL.execute help

Entirely my fault.

Add the following line before the line
"("jdbc:sqlserver://:"

driver = Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver").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.

/niclas
Product Guy for Ready! API, SoapUI and all things API
New Here?
Join us and watch the welcome video:
Announcements
Top Kudoed Authors