home | career | drupal | java | mac | mysql | perl | scala | uml | unix

Groovy example source code file (SqlWithTypedResultsTest.groovy)

This example Groovy source code file (SqlWithTypedResultsTest.groovy) is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Java - Groovy tags/keywords

by, by, from, groovy, groovy, integer, order, select, sqlwithtypedresultstest, sqlwithtypedresultstest, testhelper, testhelper

The Groovy SqlWithTypedResultsTest.groovy source code

package groovy.sql

/**
 * @author Thomas Heller
 * @version $Revision: 16054 $
 */
class SqlWithTypedResultsTest extends TestHelper {

    void testSqlQuery() {
        def sql = createEmptySql()

        sql.execute("create table groovytest ( anint integer, astring varchar )");

        def groovytest = sql.dataSet("groovytest")
        groovytest.add(anint: 1, astring: "Groovy")
        groovytest.add(anint: 2, astring: "rocks")

        Integer id

        sql.eachRow("SELECT * FROM groovytest ORDER BY anint") {
            println "found ${it.astring} for id ${it.anint}"
            id = it.anint
        }

        assert id == 2
        sql.close()
    }
}

Other Groovy examples (source code examples)

Here is a short list of links related to this Groovy SqlWithTypedResultsTest.groovy source code file:

new blog posts

 

Copyright 1998-2013 Alvin Alexander, alvinalexander.com
All Rights Reserved.