H2 database using groovy from scriptrunner

Was able to get past the connection using groovy script in scriptrunner, however the query is saying the table does not exists, it says JIRAISSUE not found.


Could somebody please help on this?



import groovy.sql.Sql
import java.sql.Driver
def driver = Class.forName('org.h2.Driver').newInstance() as Driver
def props = new Properties()
props.setProperty("user", "sa")
props.setProperty("password", "")
def conn = driver.connect("jdbc:h2:~/test", props)
def sql = new Sql(conn)
try {
{ log.debug(it) }
} finally {



3 answers

0 vote

I'd strongly recommend NOT trying to do this.  The H2 database is not a system you should be using in production, so your work is pretty much pointless anyway, and, more importantly, your approach is incorrect - you should not be trying to read the database.

If you need to know how many issues there are in a JIRA in a script, use the system information api, or run a blank JQL query and ask the result for .size.  Both those methods are database agnostic, faster and don't risk inaccuracy or damage.

Thanks Nic.


Currently i am doing an POC on JIRA and one of the action item is to pick the values from specific table from external DB (oracle or SQL) and populate in  JIRA custom field.

As of now, i dont have acess to these DB's and want to show this to my leaders that  this can be achieved from 



Any help on this will be greatly appreciated.


Ok, I would stay well away from the JIRA database when doing this.  You really need to use the API to do the population of the fields (you can't do it with database access). 

In this case, I would set up a new, empty database server (a simple Postgres or MySQL database server running locally) and set up your code to show you can read tables from that and use the API to do things with the read data in JIRA.

0 vote

Why don't you have a look at the db - https://confluence.atlassian.com/jirakb/accessing-jira-s-h2-embedded-database-776818136.html

Perhaps the case is wrong or you need to prefix with the schema.

Suggest an answer

Log in or Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Bridget Sauer
Published 4 hours ago in Marketplace Apps

Calling all developers––You're invited to Atlas Camp 2018

 Atlas Camp   is our developer event which will take place in Barcelona, Spain  from the 6th -7th of   September . This is a great opportunity to meet other developers and get n...

26 views 0 2
Read article

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