![](/img/trans.png)
[英]Windows Authentication for SQL Server using JBDC on a Mac
[英]Execute a SQL Server Procedure using SoapUI JBDC Request
SmartBear支持論壇上的話題很多,人們面臨着同樣的問題。 有時存儲過程返回更新的行數,有時不返回。 大多數人最終都訴諸Groovy。
因此,這是一個調用存儲過程schemaname.calcs
的示例,該過程使用兩個整數IN參數和四個整數OUT參數:
import groovy.sql.Sql
def url = 'full JDBC URL' // e.g. 'jdbc:sqlserver://127.0.0.1:1433/database'
def user = 'username'
def password = ''
def driver = 'driver class'
def sql = Sql.newInstance(url, user, password, driver)
sql.call( "{call schemaname.calcs(?, ?, ?, ?, ?, ?)}", [ 10,2, Sql.INTEGER , Sql.INTEGER, Sql.INTEGER, Sql.INTEGER],
{ outParameter1, outParameter2, outParameter3, outParameter4 ->
log.info("Result 1 '${outParameter1}'")
log.info("Result 2 '${outParameter2}'")
log.info("Result 3 '${outParameter3}'")
log.info("Result 4 '${outParameter4}'")
})
sql.close()
或者,調用返回結果集的存儲過程schemaname.show_contacts()
:
def result = []
sql.eachRow('call schemaname.show_contacts()') {
result << "$it.contact_name $it.phone_number"
}
比使用JDBC測試步驟容易。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.