Forum Discussion

Marcel_Brökel's avatar
Marcel_Brökel
Occasional Contributor
16 years ago

datasink writing to mysql database problems

Hi,

i tried to prepare some datadriven testsuits. To get the testdata i use an XAMMP with mysql database. Everything works, but writing back data to the database seens al litle bit 'mysterious'.

I tried two cases:

first i have set the update statement within the datasink step like this:

INSERT into result_checkAddress (
      test_id,
      execution_id,
      input_data,
      output_data,
      test_result,
      test_comment
)
VALUES (
      '${Test Result Data#testId}',
      '${Test Result Data#executionId}',
      '${Test Result Data#inputData}',
      '${Test Result Data#outputData}',
      if (STRCMP(
            'IFNULL(${Test Result Data#resultCode},'')',
            '${Test Result Data#expectedResultCode}'
            ),
      'NOTOK', 'OK'
      ),
      'Comment'
)

'Test Result Data' is an Property step and the properties are moved to this step before.

== > there are written data into the database, but although two different datasets are used (and logged as processed in the different logs within the teststeps) only ONE dataset is written back to the database, but TWO times !!

I tried another way:

INSERT into result_checkAddress (
      test_id,
      execution_id,
      input_data,
      output_data,
      test_result,
      test_comment
)
VALUES (
      '${result_checkaddress#testId}',
      '${result_checkaddress#executionId}',
      '${result_checkaddress#inputData}',
      '${result_checkaddress#outputData}',
      if (STRCMP(
            IFNULL(${result_checkaddress#resultCode},''),
            '${result_checkaddress#expectedResultCode}'
            ),
      'NOTOK', 'OK'
      ),
      'Comment'
)

'result_checkaddress' is the datasink step itself and the properties are moved to this before.

==> I've tried everything i mentioned, but every time i got the error message 'java.sql.SQLException: Parameter out of range (0 1).'

As i guess, it could mean the types does not match, or the number of parameters is not correct. But for me it seems everything schould be ok.

I have no more ideas where the fault is hidden, maybe someone has any idea how to solve my problem ?

Greets and thanks a lot ..
Marcel

7 Replies

  • omatzura's avatar
    omatzura
    Super Contributor
    Hi!

    the JDBC DataSinks sql statement is treated as a prepared statement, where the properties are assigned in the order they are defined, ie try changing the sql to


    INSERT into result_checkAddress (
          test_id,
          execution_id,
          input_data,
          output_data,
          test_result,
          test_comment
    )
    VALUES (
          ?,
          ?,
          ?,
          ?,
          if (STRCMP(
                'IFNULL(?,'')',
                '?}'
                ),
          'NOTOK', 'OK'
          ),
          'Comment'
    )


    And then see to it that you have 6 properties in your datasink; their values need to be set before the DataSink is executed (they can also contain property-expansions which will be expanded accordingly).

    Hope this helps!

    regards,

    /Ole
    eviware.com
  • Marcel_Brökel's avatar
    Marcel_Brökel
    Occasional Contributor
    Hi,

    sorry but i tried it hardly again in much different way - complex or simple, the only way it works is the properties are static.

    all properties are set and i use a very simple insert statement and althoug i got the error message above.


    ========================

    insert into result_checkaddress (
          test_id,
          execution_id,
          input_data,
          output_data
          )
    values (
          ?,
          ?,
          ?,
          ?
    )

    =========================

    i have no more ideas ..       
  • omatzura's avatar
    omatzura
    Super Contributor
    Hi!

    can you show me the definition of the result_checkaddress table so I can test this locally? Thanks in advance!

    regards,

    /ole
    eviware.com
  • Marcel_Brökel's avatar
    Marcel_Brökel
    Occasional Contributor
    CREATE TABLE IF NOT EXISTS `result_checkaddress` (
      `RESULT_ID` int(10) unsigned NOT NULL auto_increment,
      `TEST_ID` mediumtext NOT NULL,
      `EXECUTION_ID` mediumtext NOT NULL,
      `INPUT_DATA` mediumtext NOT NULL,
      `OUTPUT_DATA` mediumtext NOT NULL,
      `TEST_RESULT` mediumtext,
      `TEST_COMMENT` mediumtext,
      PRIMARY KEY  (`RESULT_ID`)
    ) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=333 ;


    i use server version 5.0.51a
    and mysql-connector-java-5.1.6-bin.jar
  • Marcel_Brökel's avatar
    Marcel_Brökel
    Occasional Contributor
    Hi Ole,

    thank you very much for your quick help.
    The new version works in the expected way !!

    thank !
    Marcel
  • Hi There -
    We are also experiencing this problem with PostgreSQL and soapui-pro 2.0.2.  Can you please clarify what we need to do in order to correct the problem (i.e. should we upgrade to a new version of soapui-pro??)

    Thanks,
    Ben
  • Marcel_Brökel's avatar
    Marcel_Brökel
    Occasional Contributor
    i can't say anything about PostgreSQL, but for MySQL the new version works.