How to connect to PostgreSQL using JNDI

お困りですか?

アトラシアン コミュニティをご利用ください。

コミュニティに質問

このページの内容は、Jira アプリケーションでサポートされていないプラットフォームに関連しています。したがって、アトラシアンは、そのためのサポートの提供を保証できません 。この資料は情報提供のみを目的としているため、お客様自身の責任でご使用ください。

目的

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.

(info) 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.


ソリューション


This solution is based on Apache Tomcat documentation.


  1. Open $JIRA_INSTALL/conf/server.xml. Within the Context element, configure a Resource element of type="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 ...>
                    <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
    <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>

最終更新日 2022 年 9 月 8 日

この内容はお役に立ちましたか?

はい
いいえ
この記事についてのフィードバックを送信する
Powered by Confluence and Scroll Viewport.