groovy-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GroovyBeginner <groovybegin...@gmail.com>
Subject Better Approach to fetch entire data from the table Groovy Sql
Date Wed, 27 Jul 2016 16:58:08 GMT
I am trying to fetch entire data from a table and the outcome should be a
comma seperated string. Here is my code which is working fine. 

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 * FROM employee") { 
temp1=it.toRowResult().values().join(", ") 
if(temp=="") 
            { 
             temp=temp1; 
            } 
else 
            { 
             temp=temp+"\n"+temp1 
            } 
              
}

Is there any better approach of doing this which can increase the
performance



--
View this message in context: http://groovy.329449.n5.nabble.com/Better-Approach-to-fetch-entire-data-from-the-table-Groovy-Sql-tp5734309.html
Sent from the Groovy Dev mailing list archive at Nabble.com.

Mime
View raw message