Declaring JNDI Datasources in AMPS
This page describes how to declare a datasource in AMPS.
JNDI Datasources are useful when:
- A plugin needs to access another database than the default one,
- You want the product to store its data in the database you specify: Postgres, MySQL, ...
The datasource support was introduced by AMPS-737.
|Use the datasource through a plugin||Use the datasource for the product's data|
|JIRA using AMPS||Yes||No|
|All other products||Yes||N/A|
You can go through the setup of Confluence and tell it to use the datasource you've just provided, such as jdbc/DefaultDS. For JIRA, it is a little more complicated: You need to declare the file dbconfig.xml.
You can checkout this example on BitBucket: Examples using JNDI datasources for JIRA and Confluence.
Declare the datasource in the pom.xml
In the following example, we declare the JNDI datasource jdbc/DefaultDS and make it target a local Postgres instance.
Notice how we set the Data Path to an empty directory: If you start Confluence using an empty Home, the setup process will be displayed. During the setup process, you will have the opportunity to tell Confluence to store its data in the JNDI datasource java:comp/env/jdbc/DefaultDS.
Start your product
Using the previous pom.xml, you can start the product using:
This feature relies on CodeHaus Cargo to launch Tomcat with the datasource. You can get more understanding of the properties by reading Cargo Configuration for Tomcat 6.x .
|jndi||-||The JNDI string for application to lookup|
|driver||-||The class of the JDBC driver, such as "org.hsqldb.jdbcDriver"|
|url||-||The JDBC url, such as jdbc:hsqldb:/path/to/database|
|username||-||The username to connect to the database|
|password||-||The password to connect to the database|
|type||Will not be sent to Cargo if empty||The type of driver, such as "java.sql.Driver" or "javax.sql.XSDataSource"|
|transactionSupport||Will not be sent to Cargo if empty||LOCAL_TRANSACTION or XQ_TRANSACTION|
|properties||Will not be sent to Cargo if empty||Properties to pass to the driver. Semi-colon delimited string.|
|cargoString||Will be built using the other values if empty||Instead of providing any other value, you can directly pass the string for Cargo|
There is no user interface to tell JIRA to use the provided datasource to store its data. However, it is still possible to use AMPS to declare the datasource; You will just need to provide JIRA with the dbconfig.xml. Please open the BitBucket repository for an example: Examples using JNDI datasources for JIRA and Confluence