Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Use Jira connection pool for plugin

Graeme Mitchell April 3, 2013

I'd like to know if it's possible to utilise the Jira database connection pool in my own plugin.

At the moment, if I want to talk to the DB I have to create my own connection to the DB. Ideally I'd like to be able to grab a connection from connection pool jira uses already for the application. Is this possible?

4 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

3 votes
Answer accepted
Onkar Ahire
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 3, 2013

org.ofbiz.core.entity.jdbc.SQLProcessor sqlProcessor=null;

sqlProcessor=new org.ofbiz.core.entity.jdbc.SQLProcessor("defaultDS");

String query = "QUERY";

ResultSet rs=sqlProcessor.executeQuery(query);

Graeme Mitchell April 3, 2013

In this example, "defaultDS" is passed as the helperName / datasource. I presume you would normally pass the connection string to the DB in here, but that sounds like it might then create a new pool? Or does the pool have a name which you can pass in here?

Onkar Ahire
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 3, 2013

JIRA will pool the property from dbconfig.xml

Onkar Ahire
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 3, 2013

data source is located in the jira_home/conf/server.xml

Graeme Mitchell April 3, 2013

I'm sorry, but I'm looking in server.xml and I don't see anything screaming out as datasource. Under which node is it stored?

Thomas Heyne
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 3, 2013

from JIRA 4 it is /home/dbconfig.xml

"deafultDS" is the default name of the datasource, until it is not custimzed in your dbconfig.xml it should be used in your plug-in code that way

Graeme Mitchell April 3, 2013

I'm on Jira 5. Let me try with defaultDS as I certainly don't recall changing anything when it was setup. If this works I'm good, but then it would still be interesting to know where this is defined.

0 votes
Rachan June 10, 2015

Hi,

I am also trying the above. The sqlProcessor object has below value i.e conn is null

commitMode:EXPLICIT_COMMIT | conn:null | SQL : 'null'

Am i missing anything in the configuration?

Graeme Mitchell June 11, 2015

Can you post some example code?

0 votes
Thomas Heyne
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 3, 2013

in /home/dbconfig.xml

<jira-database-config>
  <name>defaultDS</name>
  <delegator-name>default</delegator-name>
  <database-type>mysql</database-type>
  <schema-name></schema-name>
  <jdbc-datasource>
    <url>jdbc:mysql://localhost:yourport/yourdbname?useUnicode=true&characterEncoding=yourencoding&sessionVariables=storage_engine=InnoDB</url>
    <driver-class>com.mysql.jdbc.Driver</driver-class>
    <username>yourusername</username>
    <password>yourpassword</password>
    <pool-size>15</pool-size>
    <validation-query>select 1</validation-query>
  </jdbc-datasource>
</jira-database-config>

Graeme Mitchell April 3, 2013

Perfect, got in!! Thanks guys!

0 votes
Graeme Mitchell April 3, 2013

Alternatively if this is not possible, I would like to pool my own connections once the plugin starts. Where is the best place to implement this? I presume somewhere in the interface for our plugin?

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

TAGS
AUG Leaders

Atlassian Community Events