Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

hi,Link to mysql database via jira JMWE.Can someone help?

haiyaner August 28, 2019

jira3.png

1 answer

0 votes
Andrew
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 28, 2019

Hi @haiyaner ,

Looks similar: 

https://community.atlassian.com/t5/Marketplace-Apps-Integrations/Groovy-script-accessing-MySQL-database-works-in-Script-Runner/qaq-p/364831

In scriptrunner I use next:

import com.atlassian.jira.component.ComponentAccessor
import groovy.sql.Sql
import org.ofbiz.core.entity.ConnectionFactory
import org.ofbiz.core.entity.DelegatorInterface

import java.sql.Connection

def delegator = (DelegatorInterface) ComponentAccessor.getComponent(DelegatorInterface)
String helperName = delegator.getGroupHelperName("default");

def sqlStmt = """
SELECT * FROM jiradb.audit_log where SUMMARY='Project created';
"""
def result
Connection conn = ConnectionFactory.getConnection(helperName);
Sql sql = new Sql(conn)

try {
StringBuffer sb = new StringBuffer()
sql.eachRow(sqlStmt) {
sb << "${it.created} | ${it.author_key} | ${it.object_name}; \n"
}
result = sb.toString()
//log.error sb.toString()
}
finally {
sql.close()
}

return result

 

B.R.

haiyaner August 28, 2019

hi,I have a link to the MySql database at scriptrunner,But I want to link the MySql database in the JMWE plug-in,And then there's the problem in the figure above

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events