Forum Discussion

alibaba82's avatar
alibaba82
Super Contributor
17 years ago

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

  • 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