Forum Discussion

easyfish's avatar
easyfish
Contributor
8 years ago
Solved

can not update oracle table in soapui groovy

Hi,
I am doing data driven testing. My requirement is to take data from request properties and response properties then insert or update oralce table.
Now I can take data from properties and can select data from table. The update or delete can never success. I did google  and find no solution. Stuck here. Could you please help?

-

-----Groovy Code------
import groovy.sql.Sql
import oracle.jdbc.driver.OracleTypes

//Establish JDBC Connection to the DB
def con = Sql.newInstance("jdbc:oracle:thin:@127.0.0.1:1521:XE", "TESTDB", "TESTDB", "oracle.jdbc.driver.OracleDriver");
def comcode = con.rows("select * from DDT where TEST_STEP_ID='3.3.3'")
log.info(comcode[0])

sql.executeUpdate("UPDATE DDT SET I_COMMODITY_CODE='99999' where TEST_STEP_ID='3.3.3'")
con.close()

-----End of Groovy Code------


Error message:
Groovy.lang.MissingPropertyException: No such property:sql for class:Sript1 error at line xx.

 

  • In what line does this error happen? Did you test your connection string (it can be done using soapui interface)?

     

    Also this part looks confusing to me, you connection is called con not sql

    sql.executeUpdate("UPDATE DDT SET I_COMMODITY_CODE='99999' where TEST_STEP_ID='3.3.3'")

     

    Shouldn't it be con.executeUpdate("UPDATE DDT SET I_COMMODITY_CODE='99999' where TEST_STEP_ID='3.3.3'")?

     

    And I belive you need import of goovy.sql.*

5 Replies

  • Sorry I can not remove the smiling faces. It is because the system convert ': o' and ': S' to faces.

  • nmrao's avatar
    nmrao
    Champion Level 3
    Looks the error is trivial.
    Please use 'Sql' instead of 'sql' and see if that helps.
    • easyfish's avatar
      easyfish
      Contributor

      Thanks for your reply.

      It does not help efter change from Sql to sql. It  popup another error as below. I even  tried to add import groovy.sql.* . it also does not work.

       

       

      org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: Script8.groovy: 2: unable to resolve class groovy.sql.sql @ line 2, column 1. import groovy.sql.sql ^ org.codehaus.groovy.syntax.SyntaxException: unable to resolve class groovy.sql.sql @ line 2, column 1. at org.codehaus.groovy.ast.ClassCodeVisitorSupport.addError(ClassCodeVisitorSupport.java:149) at org.codehaus.groovy.control.ResolveVisitor.visitClass(ResolveVisitor.java:1225) at org.codehaus.groovy.control.ResolveVisitor.startResolving(ResolveVisitor.java:178) at org.codehaus.groovy.control.CompilationUnit$11.call(CompilationUnit.java:651) at org.codehaus.groovy.control.CompilationUnit.applyToSourceUnits(CompilationUnit.java:931) at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:593) at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:542) at groovy.lang.GroovyClassLoader.doParseClass(GroovyClassLoader.java:298) at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:268) at groovy.lang.GroovyShell.parseClass(GroovyShell.java:694) at groovy.lang.GroovyShell.parse(GroovyShell.java:706) at groovy.lang.GroovyShell.parse(GroovyShell.java:742) at groovy.lang.GroovyShell.parse(GroovyShell.java:733) at com.eviware.soapui.support.scripting.groovy.SoapUIGroovyScriptEngine.compile(SoapUIGroovyScriptEngine.java:138) at com.eviware.soapui.support.scripting.groovy.SoapUIGroovyScriptEngine.run(SoapUIGroovyScriptEngine.java:89) at com.eviware.soapui.support.scripting.groovy.SoapUIProGroovyScriptEngineFactory$SoapUIProGroovyScriptEngine.run(SoapUIProGroovyScriptEngineFactory.java:79) at com.eviware.soapui.impl.wsdl.teststeps.WsdlGroovyScriptTestStep.run(WsdlGroovyScriptTestStep.java:156) at com.eviware.soapui.impl.wsdl.panels.teststeps.GroovyScriptStepDesktopPanel$RunAction$1.run(GroovyScriptStepDesktopPanel.java:263) at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.lang.Thread.run(Unknown Source) 1 error

  • NataliaB's avatar
    NataliaB
    Occasional Contributor

    In what line does this error happen? Did you test your connection string (it can be done using soapui interface)?

     

    Also this part looks confusing to me, you connection is called con not sql

    sql.executeUpdate("UPDATE DDT SET I_COMMODITY_CODE='99999' where TEST_STEP_ID='3.3.3'")

     

    Shouldn't it be con.executeUpdate("UPDATE DDT SET I_COMMODITY_CODE='99999' where TEST_STEP_ID='3.3.3'")?

     

    And I belive you need import of goovy.sql.*

    • easyfish's avatar
      easyfish
      Contributor

      Thanks so much!

      It should be con.executeUpdate("UPDATE DDT SET I_COMMODITY_CODE='8888' where TEST_STEP_ID='3.3.3'")