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 votes

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.

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
Community showcase
Published Feb 07, 2019 in Marketplace Apps

A Timeless Love Story

It started as any story starts, on a normal, rainy day.   Admin meets App, and her name was Klok2, and like any first relationship we were both trying to make it work but neither one knew what...

444 views 8 26
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