All of the examples listed above run the application against an in-memory HSQLDB database. Obviously though at some point you’ll want to persist your data against an external database.
To do so just requires that overriding four configuration properties that specify the JDBC driver, JDBC URL, user and password. It also (of course) requires that the JDBC driver is configured as a <dependency>
in the webapp’s pom.xml
.
For example, to run the quickstart application against SQL Server:
-
create a new and empty database, eg myappdb
, with corresponding user and password, myappdbo/s3cr3t!
, say.
-
download the mssql-jdbc-6.2.1.jre8.jar
driver, and install locally using:
mvn install:install-file -Dfile=mssql-jdbc-6.2.1.jre8.jar \
-DgroupId=com.microsoft.sqlserver \
-DartifactId=jdbc \
-Dversion=6.2.1 \
-Dpackaging=jar
-
edit the webapp/pom.xml
to include the sqljdbc4 driver:
<profile>
<id>jdbc-mssql</id>
<activation>
<property>
<name>!skip.jdbc-mssql</name>
</property>
</activation>
<dependencies>
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>jdbc</artifactId>
<version>6.2.1</version>
</dependency>
</dependencies>
</profile>
-
change (by simply editing in isis.properties
) or override (eg by passing in as -D
system properties) the following configuration properties:
isis.persistor.datanucleus.impl.javax.jdo.option.ConnectionDriverName=com.microsoft.sqlserver.jdbc.SQLServerDriver
isis.persistor.datanucleus.impl.javax.jdo.option.ConnectionURL=jdbc:sqlserver://localhost:1433;instance=.;databaseName=myappdb
isis.persistor.datanucleus.impl.javax.jdo.option.ConnectionUserName=myappdbo
isis.persistor.datanucleus.impl.javax.jdo.option.ConnectionPassword=s3cr3t!
For example, an IntelliJ launch configuration can specify system properties:
where the system properties dialog is:
When the application has started the tables should have been automatically created (by virtue of the isis.persistor.datanucleus.impl.datanucleus.schema.autoCreateAll=true
configuration property in isis.properties
):
with 10 SimpleObject
instances created through the fixture:
|
If running against a persistent datastore, then remember that the fixture script should only be run the very first time you run up the application. Thereafter, switch to the regular app manifest (domainapp.appdefn.DomainAppAppManifest ); otherwise you’ll likely get INSERT errors on start up (trying to re-insert the same dummy data).
|