Use join
, e.g.,
tripIds.join(", ")
Tangential
If you want to create a list from another list you generally want something like map
or collect
as opposed to manually creating a list and appending to it, e.g. (untested):
def sql = Sql.newInstance("jdbc:mysql://localhost:3306/steer", "root", "", "com.mysql.jdbc.Driver")
def tripIds = sql.map { it.id }
Or if you only care about the resulting string:
def tripIds = sql.map { it.id }.join(", ")