Can't create script in post function of a transition to select data from a db table

Chow King Tak February 9, 2018

Hi,

I am using Scriptrunner on JIRA 6.4.14  with MySQL 5.7. I want to insert data to MySQL after the transition so I create a custom script post-function. I follow the code in https://scriptrunner.adaptavist.com/4.3.4/jira/recipes/misc/connecting-to-databases.html:

 

import groovy.sql.Sql
import java.sql.Driver

def driver = Class.forName('com.mysql.jdbc.Driver').newInstance() as Driver

def props = new Properties()
props.setProperty("user", "user")
props.setProperty("password", "password")

def conn = driver.connect("jdbc:mysql://server:11111/mydb", props)
def sql = new Sql(conn)

try {
sql.eachRow("select count(*) from a_table") {
log.debug(it)
print it
}
} finally {
sql.close()
conn.close()
}

 

Unfortunately, I can't add the above code when I press 'Add' button. The screen stay still with the indicator spinning forever in the lower left hand corner. 

I find that the problem comes from the select statement. So I change it to "select version()" and I can add the code and the code runs fine. It seems that I cannot create the script with "Select * from a_table" or "select col form a_table".

Any help/suggestion is appreciated, thanks in advanced.

0 answers

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events