On 6 Jan 2015 at 02:53:36, Bryn Jeffries
(bryn.jeffries@sydney.edu.au(mailto:bryn.jeffries@sydney.edu.au)) wrote:
  I finally got a JDNI connection pool working, at least
with Java, and presumably Groovy will work too with the same code. The main problem was
that the documented Tomcat convention of using a context file at WEB_INF/context.xml
wasn't working, and so the connection details weren't being read. I finally solved
this by putting the Resource details into xwiki.xml instead. In case it's of any help
to others I've added the details to
http://extensions.xwiki.org/xwiki/bin/view/Extension/Execute+SQL#HUsingaJND…
Thanks Bryn!
Note that we had a regression regarding JNDI (it got broken in 6.4M2) that I fixed
at 
http://jira.xwiki.org/browse/XWIKI-11706
Thanks
-Vincent
  Regards,
 Bryn
 ________________________________________
 From: Bryn Jeffries [bryn.jeffries(a)sydney.edu.au]
 Sent: 23 December 2014 14:31
 To: users(a)xwiki.org
 Subject: [xwiki-users] Using a JDNI DataSource for connection pooling
 I've been exploring connection pooling for an external database, but I'm
struggling to use it. I'm running XWiki 6.3 on a Ubuntu server. In
/etc/xwiki/context.xml I have
  auth="Container" 
type="javax.sql.DataSource"
 username="dbuser"
 password="dbpass"
 driverClassName="org.postgresql.Driver"
 url="jdbc:postgresql:alertdb"
 maxActive="10"
 maxIdle="4" />
 And I have a symlink to this at /usr/lib/xwiki/WEB-INF/context.xml
 I'm trying to test that I can access this with a Groovy script. I'm not entirely
sure of the correct approach here, but the most successful I've got it with
 {{groovy}}
 import groovy.sql.Sql
 import javax.naming.Context
 import javax.naming.InitialContext
 import javax.sql.DataSource
 Context ctx = new InitialContext();
 DataSource dataSource = (DataSource) ctx.lookup("jdbc/mydbds");
 def sql = new Sql(dataSource)
 {{/groovy}}
 However this fails with
 javax.naming.NameNotFoundException: Name [jdbc/mydbds] is not bound in this Context.
Unable to find [jdbc].
 Would anyone be able to tell me whether this is the right sort of way to be going about
using a JNDI resource, and what's wrong with my implementation?