pamelaloh
15 years agoOccasional Contributor
HELP: obtaining details for JDBC test steps
Hi,
I saw this topic in the SoapUI Pro Support, but unfortunately I wasn't granted access to post in that forum despite I'm a SoapUI Pro user.
I was working along the same issue raised in this thread:
I had these in my groovy script initially:
def sql = groovy.sql.Sql.newInstance('jdbc:postgresql://host:port/database?user=username&password=password',
'username', 'password', 'org.postgresql.Driver')
def purchase_tx_id = context.expand( '${partner-purchase-request-mandatory-only#Response#//purchase-response[1]/transaction-id[1]}' )
sql_str = "select id, amount, purchase_locale, payment_status, payment_currency from payment_transactions where cast(ID as text) = '${purchase_tx_id}'"
def tx = sql.firstRow(sql_str)
if ( (purchase_tx_id != tx.id )
comparison for db verification
I want to use JDBC Request instead to replace the connection to DB due to the frequency of changes of database, hence i've replaced it with:
jdbcRequest = testRunner.testCase.testSteps["JDBC Request"]
connectionString = jdbcRequest.connectionString
But I couldn't find a way to run the sql query which was previously performed by def tx = sql.firstRow(sql_str)
Can you assist me in this?
Thanks.
Pamela
I saw this topic in the SoapUI Pro Support, but unfortunately I wasn't granted access to post in that forum despite I'm a SoapUI Pro user.
I was working along the same issue raised in this thread:
to get the connection properties you need to go to the JdbcTestRequestStep itself:
jdbcRequest = testRunner.testCase.testSteps["JDBC Request"]
connectionString = jdbcRequest.connectionString
query = jdbcRequest.query
I had these in my groovy script initially:
def sql = groovy.sql.Sql.newInstance('jdbc:postgresql://host:port/database?user=username&password=password',
'username', 'password', 'org.postgresql.Driver')
def purchase_tx_id = context.expand( '${partner-purchase-request-mandatory-only#Response#//purchase-response[1]/transaction-id[1]}' )
sql_str = "select id, amount, purchase_locale, payment_status, payment_currency from payment_transactions where cast(ID as text) = '${purchase_tx_id}'"
def tx = sql.firstRow(sql_str)
if ( (purchase_tx_id != tx.id )
comparison for db verification
I want to use JDBC Request instead to replace the connection to DB due to the frequency of changes of database, hence i've replaced it with:
jdbcRequest = testRunner.testCase.testSteps["JDBC Request"]
connectionString = jdbcRequest.connectionString
But I couldn't find a way to run the sql query which was previously performed by def tx = sql.firstRow(sql_str)
Can you assist me in this?
Thanks.
Pamela