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

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Can't import certain classes from Jira API

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

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)

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?

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:

Suggest an answer

Log in or Sign up to answer

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you