Welcome to the new Parasoft forums! We hope you will enjoy the site and try out some of the new features, like sharing an idea you may have for one of our products or following a category.

How to write in Writable Data source in runtime using java

Jayaranjani_g
Jayaranjani_g Posts: 16

Hi,

How to write in Writable Data source in runtime using java. I have string value "utterances"
String utterances = utteranceSheet.getRow(i).getCell(6).toString(); which i'm getting from excel sheet. Doing this in Java using Extension tool.
Want to set this in writtable Data source.

Writable Data source name : CaptureUtterance_Table
Column Name: Utterances

Can we set like this?
etc.setValue("CaptureUtterance_Table", utterances);

Or please let me know how to write the values in writable data dource.

Comments

  • williammccusker
    williammccusker Posts: 672 ✭✭✭

    Hi,
    I am not sure about how to do it directly in java from the extension tool but you might be able to have the extension tool return the string and then chain a text data bank to the extension tool to put the value into a writable data source.

  • Jayaranjani_g
    Jayaranjani_g Posts: 16

    Im returning String at the end of the Method. How to access it in Text data bank?

  • benken_parasoft
    benken_parasoft Posts: 1,307 ✭✭✭
    edited July 2019

    Please see the earlier thread on this topic:
    Scripting: How to write to datasource?

    As mentioned, there is no public API to write to a Writable data source from a script. Only Data Bank tools do this. However, it is fairly common to use an Extension Tool to to generate data values and then chain an XML Data Bank to the output of the Extension Tool to write the return value to a Writable Data Source. Often, the script would return the data values in a simple XML document using soaptest.api.SOAPUtil.getXMLFromString(String[] values) from the public scripting API. In the XML Data Bank you would create an extraction that selects all the values and then configure the extraction to store the values in the desired Writable data source column. If you search the forum for "getXMLFromString" you can probably find other examples or old posts about using it from a script to save values using an XML Data Bank.

    On a side note, the Data Generator tool was introduced to avoid some common cases so you can generate values and write them but without scripting and having to chain multiple tools together. I'm not sure if that is something you could use in your particular case but I would always consider it first before using the Extension Tool plus Data Bank approach.