Re: Convert JDBC Result sets to xml

2016-07-31 Thread Paul King
You probably want to call toRowResult(): @Grab('org.hsqldb:hsqldb:2.3.2') @GrabConfig(systemClassLoader=true) import groovy.sql.Sql def sql = Sql.newInstance('jdbc:hsqldb:mem:MyDb', 'sa', '', 'org.hsqldb.jdbcDriver') sql.execute ''' DROP TABLE MyTable IF EXISTS; CREATE TABLE MyTable ( i

Re: Convert JDBC Result sets to xml

2016-07-31 Thread GroovyBeginner
I was trying to create the list initially in that case and then to xml with 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") def emptyList = [] sql.e

Re: Convert JDBC Result sets to xml

2016-07-31 Thread Paul King
Sure. On Sun, Jul 31, 2016 at 1:50 PM, GroovyBeginner wrote: > Can I achieve this xml output directly after querying to the db? > > > > -- > View this message in context: > http://groovy.329449.n5.nabble.com/Convert-Oracle-Result-sets-to-xml-tp5734358p5734375.html > Sent from the Groovy Dev mail

Re: Convert JDBC Result sets to xml

2016-07-30 Thread GroovyBeginner
Can I achieve this xml output directly after querying to the db? -- View this message in context: http://groovy.329449.n5.nabble.com/Convert-Oracle-Result-sets-to-xml-tp5734358p5734375.html Sent from the Groovy Dev mailing list archive at Nabble.com.

Re: Convert JDBC Result sets to xml

2016-07-29 Thread Paul King
Do you want something like this? def rows = [[ID:1, NAME:'Test1'], [ID:2, NAME:'Test2']] def mb = new groovy.xml.MarkupBuilder() mb.root { rows.each { next -> row { next.each { k, v -> "$k"(v) } } } } On Sat, Jul 30, 2016 at 3:43 AM, GroovyBeginner wrote: > Is th