I had also tried this ->
/ *Groovy code*#* /
import groovy.sql.Sql
class groovyClass {
String SQL_conn() {
def sql = Sql.newInstance("jdbc:mysql://localhost:3306/mysql",
"root","amma", "com.mysql.jdbc.Driver")
sql.eachRow("select * from db") {return "${it.Db}"}
}
}
/ *# /
but when I call the function SQL_conn() through a velocity page I only get
'$groovyObject.SQL_conn()' itself as the output !!!
Can you please show me the API ?
vmassol wrote:
Hi,
Don't call the database directly. XWiki offers API for doing this.
What tutorial are you referring to?
Thanks
-Vincent
On Oct 30, 2007, at 11:53 AM, V. Harikrishnan Nair wrote:
Hi all...
I am learning how to read from the default xwiki database xwiki_db
using
groovy. This is the code I got from the tutorial ->
-------------
import groovy.sql.Sql
sql =
Sql.newInstance("jdbc:jtds:sqlserver://serverName/dbName-
CLASS;domain=domainName",
"username",
"password", "net.sourceforge.jtds.jdbc.Driver")
sql.eachRow("select * from tableName", { println it.id + " --
${it.firstName} --"} );
------------
This is the code which is edited by me ->
-----------
import groovy.sql.Sql
sql =
Sql.newInstance("jdbc:jtds:sqlserver://localhost/xwiki_db-
CLASS;domain=domainName",
"sa",
"", "net.sourceforge.jtds.jdbc.Driver")
sql.eachRow("select * from XWIKIDOC", { println it.id + " -- $
{it.firstName}
--"} );
----------
Can anyone please rectify any errors here ? Especially the closure
in the
third line as I don't know the fields present in XWIKIDOC table...
Thanks,
Harikrishnan
_______________________________________________
users mailing list
users(a)xwiki.org
http://lists.xwiki.org/mailman/listinfo/users