[英]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.