General Actions:
Log-in
Register
Wiki:
Main wiki
▼
:
Document Index
»
Space:
Sandbox
▼
:
Document Index
»
Page:
dblookup
Search
en
Page Actions:
Export
▼
:
Export as PDF
Export as RTF
Export as HTML
More actions
▼
:
Print preview
View Source
dblookup
Wiki source code of
dblookup
Last modified by
Administrator
on 2010/10/28 16:28
Content
·
Comments
(0)
·
Annotations
(0)
·
Attachments
(0)
·
History
·
Information
Hide line numbers
1: 2: {{groovy}} 3: import javax.naming.*; 4: import groovy.sql.Sql 5: 6: Context initCtx = new InitialContext() 7: Context ctx = initCtx.lookup("java:/comp/env") 8: 9: def datasource = ctx.lookup("jdbc/demo") 10: 11: def db = new Sql(datasource) 12: 13: db.rows("select fname, lname, company from customer where state = ?", ["CA"], {println(it)}) 14: 15: {{/groovy}}