Access to ActiveObjects tables via JDBC?

I wonder if I can get a JDBC connection to the JIRA/Confluence database from plugin code and access the tables created by the ActiveObjects plugin.

Is that possible?

If so: Would that still work reliably on a different JIRA/Confluence instance with different configuration, specifically with a different database vendor?

2 answers

1 accepted

This widget could not be displayed.

You can definitely get the DS info or Connection from plugin code and use it to access AO tables.

DatasourceInfo datasourceInfo = new DefaultOfBizConnectionFactory().getDatasourceInfo();
Connection connection = new DefaultOfBizConnectionFactory().getConnection();

AO tables follows a unique naming strategy, which you can find at https://developer.atlassian.com/docs/atlassian-platform-common-components/active-objects/developing-your-plugin-with-active-objects/active-objects-faq/table-names. The names stay the same across instances.

Having said that, it is recommended to use the ActiveObjects APIs to interact with the AO tables. 

Thanks a lot, Jobin, I will try that! Are you aware of specific dangers of accessing AO tables directly view JDBC?

Not really. I mostly opt for AO APIs but have done it via direct JDBC calls for complex scenarios. Other than that, it is normal JDBC!

Is there a way to make that work for Confluence? I can only find DefaultOfBizConnectionFactory in the com.atlassian.jira.ofbiz package.

I get null when I try accessing JDBC info 

JdbcDatasourceInfo jdbcDatasourceInfo = new DefaultOfBizConnectionFactory().getDatasourceInfo().getJdbcDatasource(); 

However the JNDI Datasource works

DefaultOfBizConnectionFactory().getDatasourceInfo().getJndiDatasource()

 

Any clues ?

I am using SDK with 

<jira.version>7.2.2</jira.version><amps.version>6.2.11</amps.version>

It seems to be SDK version issue.

It works when I change JIRA & AMPS version to the one below

<jira.version>6.3.1</jira.version>
<amps.version>5.0.3</amps.version>

This widget could not be displayed.
Daniel Wester Community Champion Jan 10, 2017

Be very careful. AO does have some caching built in so if you mix the access algorithm (API vs direct jdbc) you might see some strange results.

Suggest an answer

Log in or Sign up to answer
Atlassian Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Posted Aug 06, 2018 in Jira Service Desk

A is for Activate: Share your top Jira Service Desk onboarding tips for new users!

Hi, everyone! Molly here from the Jira Service Desk Product Marketing Team :).  In the spirit of this month's  august-challenge, we're sourcing stories of Jira Service Desk activation fro...

576 views 25 15
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you