Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Won't Fix
-
1.0-beta-3
-
None
-
None
-
Win2K, Tomcat 4.1.24, CVS head as of now
Description
This code snippet works in my groovlet:
sql.queryEach("SELECT * FROM WebContentPageType") {
out.println("key: ${it.pageNameKey}")
}
This one doesn't:
sql.queryEach("SELECT * FROM WebContentPageType")
{
out.println("key: ${it.pageNameKey}")
}
The only difference is the placement of the block closure bracket.
In case it will help, below is the stack trace, the exact scriptlet code, and the exact output from the scriptlet that does not work. (I'm using the latest CVS code on Win2K with Tomcat 4.1.24). Any ideas would be greatly appreciated.
=============== Stack Trace: (why try to execute static method on an instance?)
groovy.lang.MissingMethodException: No such method: queryEach for class: groovy.sql.Sql
at groovy.lang.MetaClass.invokeStaticMethod(MetaClass.java:285)
at groovy.lang.MetaClass.invokeMethod(MetaClass.java:241)
at org.codehaus.groovy.runtime.Invoker.invokeMethod(Invoker.java:127)
at org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.java:92)
at sqlscriptlet.run(sqlscriptlet.groovy:12)
at groovy.servlet.GroovyServlet.service(GroovyServlet.java:233)
=============== Groovlet with lots of debug statements:
import javax.naming.InitialContext
import javax.sql.DataSource
import groovy.sql.Sql
import groovy.sql.DataSet
Context ctx = new InitialContext();
DataSource dataSource = (DataSource) ctx.lookup("java:comp/env/jdbc/kolc")
println("DataSource: ${dataSource}")
println("Connection: ${dataSource.connection}")
Sql sql = new Sql(dataSource)
println("Instance: ${sql}")
println("Class : ${sql.class}")
sql.queryEach("SELECT * FROM WebContentPageType")
{
out.println("key: ${it.pageNameKey} isPermanent: ${it.isPermanentContent} <BR>")
}
=============== Output:
DataSource: org.apache.commons.dbcp.BasicDataSource@1c1ac46
Connection: org.apache.commons.dbcp.PoolableConnection@61373f
Instance: groovy.sql.Sql@1f44ec7
Class : class groovy.sql.Sql