You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@groovy.apache.org by GroovyBeginner <gr...@gmail.com> on 2016/07/27 16:58:08 UTC

Better Approach to fetch entire data from the table Groovy Sql

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.