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

How to connect from plugin (script runner) do database with current context without credentials

We have Confluence DC (2 nodes) with direct connection do database (without DS) defined in server.xml.


We want to from script runner (console) get current connected and read / write some information to database without providing credentials. We know that they are resources to define, but for Jira we was able to read current APP context and do the db query directly. We don't won't multiple places where password is stored. Can anyone help mi wi this? Probably the same way is implemented in every custom plugin developed for confluence, to have ability to read database.

1 answer

0 votes

No, you absolutely do not want to do this.

You must not write to an Atlassian application's database, because you will break it.  Never do that.

As for how you use scripts to read a database, it's the same for every application, so do whatever it is you did for the Jira scripts that read your database.

On Jira I've use something like that, are you able to help me use the same code in Confluence?


import com.atlassian.core.ofbiz.CoreFactory;
import org.ofbiz.core.entity.*;
import java.sql.Connection;
import com.atlassian.jira.component.ComponentAccessor;
import groovy.sql.Sql;
GenericDelegator delegator = CoreFactory.getGenericDelegator();
String helperName = delegator.getGroupHelperName("default");
Connection conn = ConnectionFactory.getConnection(helperName);
def sql = new Sql(conn);
def rows = sql.rows('SELECT "ID", "SAVED_FILTER_ID" FROM "AO_60DB71_RAPIDVIEW"');

Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Confluence Cloud

🏠 Say hello to the new Confluence Home!

Hi Atlassian Community, My name is DJ Chung, and I’m a Product Manager on the Confluence Cloud team. Today, I’m excited to share a new and improved version of Home. The new Home helps you ...

42,910 views 30 134
Read article

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