How to write in Writable Data source in runtime using java

Jayaranjani_gJayaranjani_g Posts: 15

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

  • williammccuskerwilliammccusker Posts: 165 ✭✭

    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_gJayaranjani_g Posts: 15

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

  • benken_parasoftbenken_parasoft Posts: 736 ✭✭✭
    edited July 9

    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.

Sign In or Register to comment.