Forum Discussion

rah's avatar
rah
Occasional Contributor
15 years ago

sql UPDATE statement in Groovy -> soapUI 3.0 crashes

I'm accessing data from a data base. Which works perfectly fine for SELECT statements. But as soon as I'm trying to execute the UPDATE statement below, soapUI crashes. What am I doing wrong?

com.eviware.soapui.support.ClasspathHacker.addURL( new URL("file://{my path to the driver}/ojdbc14.jar") )

import groovy.sql.Sql

sql = Sql.newInstance(jdbcUrl, jdbcUser, jdbcPw, 'oracle.jdbc.OracleDriver')
def query = "UPDATE mytable SET object_id = -200 WHERE tag_id = -100"
result = sql.execute(query)

Thanks a lot for your help!

6 Replies

  • SmartBear_Suppo's avatar
    SmartBear_Suppo
    SmartBear Alumni (Retired)
    Hi,

    Can you please explain what you mean by "soapui crashes".
    I've tried to reproduce it, and what happens is that actually update doesn't get executed,
    i.e. nothing is updated (I get "Script-result:false")
    If so, please try sql.executeUpdate(query) instead of sql.execute(query) .
    If otherwise please elaborate what happens a little more...

    Regards,

    /Dragica
    eviware.com
  • rah's avatar
    rah
    Occasional Contributor
    Hi Dragica,

    Thanks a lot for your help and please apologies for my impreciseness.

    I tried "sql.executeUpdate(query)" but it causes the same effects as before. On the db nothing gets updated, the soapUI 3.0 GUI freezes and the only output I get in the log is

    [exec] 2009-07-23 10:24:54,295 INFO  [viware.soapui.SoapUI:57  ] [AWT-EventQueue-0] Added [file:/share/java/jpository/oracle/product/10.2.0.4.0/jdbc/lib/ojdbc14.jar] to classpath
  • SmartBear_Suppo's avatar
    SmartBear_Suppo
    SmartBear Alumni (Retired)
    Hi,

    Basically what you need to do is place your driver jar in bin/ext folder under soapui installation, define a connection on project level and then use it in groovy script.

    For details please check our User Guide at:
    http://www.soapui.org/userguide/project ... html    and
    http://www.soapui.org/userguide/functio ... vyUtilsPro

    In the same manner you can use sql.executeUpdate(query).
    Try your update using this pattern and let us know if it worked ok.

    Also, in order to get priority in getting support, please post you questions in our Pro forum.

    Regards,

    /Dragica
    eviware.com
  • rah's avatar
    rah
    Occasional Contributor
    Thanks for your fast reply.

    I purposely did not move the driver jar to bin/ext and with the ClasspathHacker.addURL statement and only SELECTs this has worked fine.

    I have copied the driver now to bin/ext as you have suggested but it does not make any difference at all.

    I am working with the open version of soapUI on Linux
  • rah's avatar
    rah
    Occasional Contributor
    I found the error. I was working on a record that did not fulfill all unique constraints.

    Now everything works perfectly fine, with result = sql.executeUpdate(myquery) and also with the driver in my preferred location (not in bin/ext).

    Thanks a lot for your support and sorry for the inconveniences!