我试图用sql.rows()Groovy方法获取一些数据,并且返回这些值需要很长时间。
所以我尝试了“标准”方式,速度要快得多(快150倍)。
我错过了什么?
看下面的代码:第一种方法返回结果大约2500毫秒,第二种方法返回15毫秒!
class MyService {
javax.sql.DataSource dataSource
def SQL_QUERY = "select M_FIRSTNAME as firstname, M_LASTNAME as lastname, M_NATIONALITY as country from CT_PLAYER order by M_ID asc";
def getPlayers1(int offset, int maxRows)
{
def t = System.currentTimeMillis()
def sql = new Sql(dataSource)
def rows = sql.rows(SQL_QUERY, offset, maxRows)
println "time1 : ${System.currentTimeMillis()-t}"
return rows
}
def getPlayers2(int offset, int maxRows)
{
def t = System.currentTimeMillis();
Connection connection = dataSource.getConnection();
Statement statement = connectio