Hi Matt,
On Sep 9, 2012, at 5:50 AM, Matt Lamoureux <mmlmrx(a)gmail.com> wrote:
Hi all,
I am trying to get a wiki page to display the tables in my DB2 database
(on an AIX system, not an OS/400). I'm confused about how to configure
Groovy to make the connection, though. I went here:
http://extensions.xwiki.org/xwiki/bin/view/Extension/Execute+SQL
So far, I have come up with this syntax:
{{groovy}}
import groovy.sql.Sql
sql = Sql.newInstance( 'jdbc:db2://AAA:BBB/CCC', 'DDD', 'EEE',
'com.ibm.db2.jcc.DB2Driver' )
sql.eachRow( 'list tables' )
{{/groovy}}
AAA = server name
BBB = port
CCC = database name
DDD = user
EEE = password
This syntax doesn't work - it results in "ClassNotFoundException" errors.
First question: do I have the syntax right?
No idea, I've never used this. I have just copied the information from
http://groovy.codehaus.org/Tutorial+6+-+Groovy+SQL and put it on
http://extensions.xwiki.org/xwiki/bin/view/Extension/Execute+SQL
Second question: I assume I have to provide Groovy
some DB2 zip/jar file,
but where should that file be placed in my Tomcat/MySQL installation?
You need to put the db2 jar In your webapp's WEB-INF/lib directory. This is probably
why you get the CNFE.
Third question: I know I will have to manipulate the
query result so that
the output will have wiki elements (like clickable links). Does anyone
have any examples of how they displayed their results, preferably with
tables and links?
You just need to use wiki syntax…
To do that from Groovy you'd use: print and println.
For ex: println "Some **bold**"
See the syntax guide to learn how to use tables/links.
Hope it helps,
-Vincent