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=="") {
        temp=temp1;
    }else{
        temp=temp+"\n"+temp1
    }          
}



--
View this message in context: 
http://groovy.329449.n5.nabble.com/Groovy-Better-Approach-to-create-comma-separated-string-from-Database-Select-Query-tp5734115.html
Sent from the Groovy Dev mailing list archive at Nabble.com.

Reply via email to