groovy sql 调用SqlServer存储过程分页

直接上代码:

import groovy.sql.*


def db = [url:'jdbc:sqlserver://xxx.xxx.xxx.xxx:1433;DatabaseName=Test', user:'sa', password:'11111111', driver:'com.microsoft.sqlserver.jdbc.SQLServerDriver']
def sql = Sql.newInstance(db.url, db.user, db.password, db.driver)
def result = [:]
def month = '2018-4'
def page = 3  //页码
def maxRows =2 //每页数据量
def offset = maxRows*(page-1)+1 //生成offset公式
def set = sql.rows("exec SP_GFGSJC_TU @GZNY = ?",[month],offset,maxRows)

def total =  sql.rows("exec SP_TEST @GZNY = ?",[month])
result.total = total.size()
result.results = set
println result 
展开阅读全文

没有更多推荐了,返回首页