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
<?xml version="1.0" encoding="UTF-8"?>
<Context>
<!-- JDBC datasource for myDB -->
<Resource name="jdbc/mydbds"
auth="Container"
type="javax.sql.DataSource"
username="dbuser"
password="dbpass"
driverClassName="org.postgresql.Driver"
url="jdbc:postgresql:alertdb"
maxActive="10"
maxIdle="4" />
</Context>
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?