groovy-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GroovyBeginner <>
Subject Groovy Better Approach to create comma separated string from Database Select Query
Date Sat, 16 Jul 2016 03:43:55 GMT
I am trying to connect to oracle database table and pull the data and form
the result in the form of comma separated values. I have written a sample
code which works fine but wanted to have a better approach if the query is
associated with more tables (joins), then the time is taken to get the
output is more. Is there any better way of improving the performance.

import groovy.sql.Sql;
import java.sql.ResultSet;

def temp="";
def temp1="";
sql = Sql.newInstance("jdbc:oracle:thin:@localhost:1521:XE","username",
"password", "oracle.jdbc.driver.OracleDriver")
sql.eachRow("select empid, empname FROM employee") {
    temp1=it.toRowResult().values().join(", ")
    if(temp=="") {

View this message in context:
Sent from the Groovy Dev mailing list archive at

View raw message