How to config Atlassian-SDK's Jira to use custom JDBC database instead of H2

Hi,

When I am developing a plugin for Jira (version 7.12), I really want to have the plugin ran on a Jira instance with my own database (such as Postgres) instead of H2. The things I did are:

  • Clean and run (atlas-run) the plugin project the first time.
  • I have the dbconfig.xml in JiraHome, I modify it content (see below).
  • atlas-run again.

The result is: When I try to visit localhost:2990/jira, I has the error page said that JIra has some error when start.

This is my dbconfig.xml custom content:

defaultDS
default
postgres72
public

jdbc:postgresql://localhost:5432/jira-sdk
org.postgresql.Driver
postgres
postgres
20
20
30000
select 1
4000
5000
20
true
300
false
true

My database server is running, I’ve checked but there is no table was generated in the database.
Don’t know if this is a problem with my configurations or I need to do it in another way/place.
Any help would be appreciated!

PS: I knew that with real Jira software, we can use config.bat (.sh) to modify the configurations, it works for me with real Jira, but the SDK’s instance doesn’t have that file.

Hello @hy.duc.nguyen,

The way I did it is to use maven-amps-plugin in my POM and declaring the datasource there. In a nutshell, I did it like this (for mySql but should be similar with Postgre)

<plugin>
	<groupId>com.atlassian.maven.plugins</groupId>
	<artifactId>maven-amps-plugin</artifactId>
	<version>${amps.version}</version>
	<extensions>true</extensions>
	<configuration>
		<productVersion>${jira.version}</productVersion>
		<productDataVersion>${jira.version}</productDataVersion>
		<instanceId>myJira</instanceId>
		<products>
			<product>
				<id>jira</id>
				<instanceId>myJira</instanceId>
				<version>${jira.version}</version>
				...
				<dataSources>
					<dataSource>
						<jndi>jdbc/JiraDS</jndi>
						<url>jdbc:mysql://localhost:3306/jira8</url>
						<driver>com.mysql.jdbc.Driver</driver>
						<username>root</username>
						<password>root</password>
						<libArtifacts>
							<libArtifact>
								<groupId>mysql</groupId>
								<artifactId>mysql-connector-java</artifactId>
								<version>5.1.22</version>
							</libArtifact>
						</libArtifacts>
					</dataSource>
				</dataSources>
			</product>
		</products>
	</configuration>
</plugin>

If you want to test your server app using a different DB, you can read more in this Declaring JNDI datasources in AMPS documentation.

Hope this helps.
Ian

1 Like