[xwiki-users] Sample Groovy Code
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 -- View this message in context: http://www.nabble.com/Sample-Groovy-Code-tf4717685.html#a13486121 Sent from the XWiki- Users mailing list archive at Nabble.com.
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
I'm refering to the groovy tutorial in http://groovy.codehaus.org/Tutorial+6+-+Groovy+SQL 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 [email protected] http://lists.xwiki.org/mailman/listinfo/users
-- View this message in context: http://www.nabble.com/Sample-Groovy-Code-tf4717685.html#a13492691 Sent from the XWiki- Users mailing list archive at Nabble.com.
Hello Vincent, I've found out QueryPluginApi from the docs. But even if this is the API you meant, why is it not possible to use Groovy to access the database of my choice to display my data ? Harikrishnan 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 [email protected] http://lists.xwiki.org/mailman/listinfo/users
-- View this message in context: http://www.nabble.com/Sample-Groovy-Code-tf4717685.html#a13502522 Sent from the XWiki- Users mailing list archive at Nabble.com.
First, you need to tell us what's your use case. What information do you wish to get from the database? Thanks -Vincent On Oct 31, 2007, at 6:19 AM, V. Harikrishnan Nair wrote:
Hello Vincent,
I've found out QueryPluginApi from the docs. But even if this is the API you meant, why is it not possible to use Groovy to access the database of my choice to display my data ?
Harikrishnan
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 [email protected] http://lists.xwiki.org/mailman/listinfo/users
-- View this message in context: http://www.nabble.com/Sample-Groovy-Code-tf4717685.html#a13502522 Sent from the XWiki- Users mailing list archive at Nabble.com.
_______________________________________________ users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users
The Xwiki system has it's own internal database structure; called using "$xwiki.search(type_hql_here)". -----Original Message----- From: [email protected] [mailto:[email protected]] On Behalf Of Vincent Massol Sent: 31 October 2007 07:01 To: XWiki Users Subject: Re: [xwiki-users] Sample Groovy Code First, you need to tell us what's your use case. What information do you wish to get from the database? Thanks -Vincent On Oct 31, 2007, at 6:19 AM, V. Harikrishnan Nair wrote:
Hello Vincent,
I've found out QueryPluginApi from the docs. But even if this is the API you meant, why is it not possible to use Groovy to access the database of my choice to display my data ?
Harikrishnan
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 [email protected] http://lists.xwiki.org/mailman/listinfo/users
-- View this message in context: http://www.nabble.com/Sample-Groovy-Code-tf4717685.html#a13502522 Sent from the XWiki- Users mailing list archive at Nabble.com.
_______________________________________________ users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users
_______________________________________________ users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users
participants (3)
-
Esbach, Brandon -
V. Harikrishnan Nair -
Vincent Massol