groovy-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GroovyBeginner <>
Subject Convert JDBC Result sets to xml
Date Fri, 29 Jul 2016 17:43:52 GMT
Is there any approach of converting the JDBC result sets to xml dynamically
with out specifying the tags in xml as column names. I am using the
following code 

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

Sql sql = Sql.newInstance("jdbc:oracle:thin:@localhost:1521:XE","username",
"password", "oracle.jdbc.driver.OracleDriver") 

StringBuilder builder = new StringBuilder()

sql.eachRow("select * FROM A") { row -> 
   builder.append( "${row}" )

return builder.toString()

This code is returning result of lists a sample output would be [ID:1,
NAME:Test1][ID:2, NAME:Test2] Is there approach of getting this output as
help would be much appreciated

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

View raw message