This page describes how to declare a datasource in AMPS.
JNDI Datasources are useful when:
The datasource support was introduced by AMPS-737.
Use the datasource through a plugin | Use the datasource for the product's data | |
---|---|---|
Confluence | Yes | Yes |
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.
In the following example, we declare the JNDI datasource jdbc/DefaultDS and make it target a local Postgres instance.
1 2<?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.atlassian</groupId> <artifactId>datasource-example</artifactId> <version>1.0-SNAPSHOT</version> <name>Datasource Example</name> <packaging>atlassian-plugin</packaging> <dependencies> <dependency> <groupId>com.atlassian.confluence</groupId> <artifactId>confluence</artifactId> <version>${confluence.version}</version> <scope>provided</scope> </dependency> <dependency> <groupId>postgresql</groupId> <artifactId>postgresql</artifactId> <version>9.1-901-1.jdbc4</version> <scope>runtime</scope> </dependency> </dependencies> <build> <plugins> <plugin> <!-- Run me with "mvn clean amps:run" --> <groupId>com.atlassian.maven.plugins</groupId> <artifactId>amps-maven-plugin</artifactId> <version>4.1</version> <extensions>true</extensions> <configuration> <instanceId>instanceId1</instanceId> <products> <product> <id>confluence</id> <instanceId>instanceId1</instanceId> <version>${confluence.version}</version> <dataPath>src/main/resources/empty-home</dataPath> <dataSources> <dataSource> <jndi>jdbc/DefaultDS</jndi> <url>jdbc:postgresql://localhost:5432/confluence</url> <username>confluence</username> <password>confluence</password> <driver>org.postgresql.Driver</driver> <libArtifacts> <libArtifact> <groupId>postgresql</groupId> <artifactId>postgresql</artifactId> <version>9.1-901-1.jdbc4</version> </libArtifact> </libArtifacts> </dataSource> </dataSources> </product> </products> </configuration> </plugin> </plugins> </build> <properties> <confluence.version>5.0-m9</confluence.version> </properties> </project>
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.
Using the previous pom.xml, you can start the product using:
1 2atlas-run
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 .
Parameter | Default Value | Description |
---|---|---|
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.XADataSource" |
transactionSupport | Will not be sent to Cargo if empty | LOCAL_TRANSACTION or XA_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
Rate this page: