How to connect to PostgreSQL using JNDI
Platform Notice: Data Center Only - This article only applies to Atlassian products on the Data Center platform.
Note that this KB was created for the Data Center version of the product. Data Center KBs for non-Data-Center-specific features may also work for Server versions of the product, however they have not been tested. Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.
*Except Fisheye and Crucible
Summary
The content on this page relates to platforms which are not supported. Consequently, Atlassian Support cannot guarantee providing any support for it. Please be aware that this material is provided for your information only and using it is done so at your own risk.
While using JavaMelody to monitor JIRA, it may be required to provide the database connection using JNDI. This page describes how to connect JIRA to PostgreSQL using JNDI parameters.
ℹ️
Please note that the JNDI parameters shown below such as
maxActive
are from Tomcat 7. In Tomcat 8+ , some of these have changed. For example,
maxActive
has been updated to
maxTotal
. For help with Tomcat 8 and above, please refer to the
KB on JNDI database connection needs an upgrade to Jira 7.x or above
.
Solution
This solution is based on Apache Tomcat documentation.
Open $JIRA_INSTALL/conf/server.xml. Within the
Context
element, configure aResource
element oftype="javax.sql.DataSource"
as in the example below. Note that you need to copy only the first<Resource ... >
from the following snippet:server.xml - <Resource ...>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
<Context path="/jira" docBase="${catalina.home}/atlassian-jira" reloadable="false" useHttpOnly="true"> <!-- The following Resource is for JNDI --> <Resource name="jdbc/jirads" auth="Container" type="javax.sql.DataSource" username="database_user" password="database_password" driverClassName="org.postgresql.Driver" url="jdbc:postgresql://localhost:5432/jira_database" connectionProperties="" maxActive="100" maxWait="10000" validationQuery="select version();" removeAbandoned="true" logAbandoned="true" testWhileIdle="true" timeBetweenEvictionRunsMillis="60000" minEvictableIdleTimeMillis="300000" /> <Resource name="UserTransaction" auth="Container" type="javax.transaction.UserTransaction" factory="org.objectweb.jotm.UserTransactionFactory" jotm.timeout="60"/> <Manager pathname=""/> </Context>
Configure the $JIRA_HOME/dbconfig.xml as follows:
dbconfig.xml
1 2 3 4 5 6 7 8 9
<jira-database-config> <name>defaultDS</name> <delegator-name>default</delegator-name> <database-type>postgres72</database-type> <schema-name>public</schema-name> <jndi-datasource> <jndi-name>java:comp/env/jdbc/jirads</jndi-name> </jndi-datasource> </jira-database-config>
Was this helpful?