Docs » Components » Objectstores » Jdo
Isis' JDO objectstore can be configured either to connect to the database using its own connection pool, or by using a container-managed datasource.
Using a connection pool managed directly by the application (that is, by Isis' JDO objectstore and ultimately by DataNucleus) requires a single set of configuration properties to be specified.
In the WEB-INF\persistor_datanucleus.properties file, specify the connection driver, url, username and password.
For example:
isis.persistor.datanucleus.impl.javax.jdo.option.ConnectionDriverName=net.sf.log4jdbc.DriverSpy isis.persistor.datanucleus.impl.javax.jdo.option.ConnectionURL=jdbc:log4jdbc:hsqldb:mem:test isis.persistor.datanucleus.impl.javax.jdo.option.ConnectionUserName=sa isis.persistor.datanucleus.impl.javax.jdo.option.ConnectionPassword=
Those configuration properties that start with the prefix isis.persistor.datanucleus.impl. are passed through directly to DataNucleus (with the prefix removed).
Using a datasource managed by the servlet container requires three separate bits of configuration.
Firstly, specify the name of the datasource in the WEB-INF\persistor_datanucleus.properties file. For example:
isis.persistor.datanucleus.impl.datanucleus.ConnectionFactoryName=java:comp/env/jdbc/quickstart
If connection pool settings are also present in this file, they will simply be ignored. Any other configuration properties that start with the prefix isis.persistor.datanucleus.impl. are passed through directly to DataNucleus (with the prefix removed).
Secondly, in the WEB-INF/web.xml, declare the resource reference:
<resource-ref>
<description>db</description>
<res-ref-name>jdbc/quickstart</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
Finally, declare the datasource as required by the servlet container. For example, if using Tomcat 7, the datasource can be specified by adding the following to $TOMCAT_HOME/conf/context.xml:
<Resource name="jdbc/quickstart" auth="Container" type="javax.sql.DataSource" maxActive="100" maxIdle="30" maxWait="10000" username="sa" password="p4ssword" driverClassName="com.microsoft.sqlserver.jdbc.SQLServerDriver" url="jdbc:sqlserver://127.0.0.1:1433;instance=.;databaseName=quickstart"/>
You will also need to make sure that the JDBC driver is on the servlet container's classpath. For Tomcat, this means copying the driver to $TOMCAT_HOME/lib.
conf/context.xml to the name of the webapp, eg conf/mywebapp.xml, and scope the connection to that webapp only. I was unable to get this working, however.