Forum Discussion

RhettS's avatar
New Contributor
10 years ago

SQL Update statement only working sometimes

I've got a test case with these steps:

1. JDBC SQL request like: UPDATE DBName..TableName set var1 = '9' WHERE var2 = '12345' AND var3 = '5'
2. JDBC SQL request like: SELECT * FROM DBName..TableName WHERE WHERE var2 = '12345' AND var3 = '5'
2.a) assert that var1 in the results from step 2 was equal to 9

Around 10% of the time, the test fails.

I've tried doing the whole thing from MS SQL Server Management Studio, and it works fine as you'd expect. I've also used a query in MS SQL Server Management Studio to confirm that, alas, around 10% of the times I run that test case the UPDATE statement does not have any effect on the server.

I am using a JDBC connection with the driver, if that helps.

So my questions is: What could possibly be causing this?


2 Replies

  • RhettS's avatar
    New Contributor
    I've found a workaround, but I'd still like to know what causes this.

    The workaround is to use this groovy script:

    import groovy.sql.Sql
    def serverName = 'jdbc:jtds:sqlserver://serverName/dbName-CLASS;domain=domainName'
    serverName = 'jdbc:sqlserver://$IP;databaseName=$DBNAME'
    def username = ''
    def password = ''
    def driver = ''

    sql = Sql.newInstance( serverName, username, password, driver )
    sql.execute( "UPDATE TableName set A = 5 WHERE B = 213" )

  • SmartBear_Suppo's avatar
    SmartBear Alumni (Retired)

    Please disable the grrovy script testStep.
    Add a JDBC request testStep,
    For using the JDBC TestStep you will need to add a JDBC driver to soapui_home/bin/ext folder and restart the application.

    Check format File > Preferences > JDBC Drivers Properties
    If your connection string is not present add it

    Add query in the request.

    For connection string, jdbc:jtds:sqlserver://servername/dbname;user=username;password=password
    you may have to add this jar, jtds-1.2.5.jar