Can't import certain classes from Jira API

Frieder Hannenheim July 22, 2021

I'm trying to write a Jira plugin. Now I want to acess the database with DatabaseAccessorImpl but that class can't be resolved. I opened the project with IDEA and looked at com.atlassian.jira.database but it only has 4 classes. The docs say there should be DatabaseAccessorImpl here but I only have DatabaseAccessor. I have API version 7.13.0

1 answer

1 accepted

0 votes
Answer accepted
Martin Bayer _MoroSystems_ s_r_o__
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
July 22, 2021

Hi @Frieder Hannenheim welcome on the community.

Jira uses OSGi as framework which solves dependencies between components. It also provides two maven dependencies

  • jira-api
  • jira-core

I guess, you have configured jira-api to be part of your maven configuration and it is correct as you should not use jira-core if not necessary.

So you really need to use com.atlassian.jira.database.DatabaseAccessor which is part of public API (it is an interface which you can use to call implementation in com.atlassian.jira.database.DatabaseAccessorImpl)

Frieder Hannenheim July 23, 2021

I was able to get a Database connection with ConnectionFactory but now I get a 

java.sql.SQLSyntaxErrorException: (conn=36516) SELECT command denied to user 'username@hostname' for table 'AO_9F39CD_TLFIELDVALUE'

 which is weird because the user has all permissions in the Database. Do I need to provide a Password? Heres's my code:

java.sql.Connection connection = ConnectionFactory.getConnection("defaultDS");
Statement s = connection.createStatement();
ResultSet result = s.executeQuery("SELECT\n" +
"max(anb.FIELDVALUELONG) as lastAccountNumber\n" +
"FROM \n" +
"et1_jira.AO_9F39CD_TLFIELDVALUE anb \n" +
"WHERE \n" +
String.format("anb.FIELDCODE='%s'", fieldcode));

 I'm trying to access data from another plugin. Is that not possible?

Martin Bayer _MoroSystems_ s_r_o__
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
July 23, 2021

No, user and password is configured in your dbconfig.xml file. I just found out you want to get data for CRM App. On Server and DC it has some REST API documented. It is standard way of how to interact with the application:

https://wiki.teamlead.ru/doc/crmjs/latest/developer-s-guide/crm-api

Frieder Hannenheim August 9, 2021

Thank you. I looked at the API briefly and thought I couldn't use it. Now I found a way that is slower than direct database access but still works fine.

Suggest an answer

Log in or Sign up to answer