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 {
sql.eachRow("SELECT COUNT(*) FROM JIRAISSUE")
{ log.debug(it) }
} finally {
sql.close()
conn.close()
}
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.
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
scriptrunner.
Any help on this will be greatly appreciated.
Thanks
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.