Can't connecto to my db in Jira DataCenter

Im trying to connecto to jira db, but the console says " No data source with name ‘defaultDS’ defined"

Can someone help me with my code?


import com.atlassian.jira.component.ComponentAccessor
import com.onresolve.scriptrunner.db.DatabaseUtil
import groovy.sql.Sql

final def dbConnectionName = ‘defaultDS’

def dbResultValue = new StringBuilder()
def output =

String sqlQuery = “”
DatabaseUtil.withSql(dbConnectionName) { sql →
output = sql.rows(sqlQuery)

}

output.collectEntries {
it
}.values().findAll {
dbResultValue.append(it.toString())
}

Hi, @sircas.
have you configured the Database item previously as explained here?

You must add the same pool name in the connection, and in the script, your case should be ‘defaultDS’.

Let me know if this helps.
Thanks, Ivan.

1 Like