Create a gist now

Instantly share code, notes, and snippets.

Embed
What would you like to do?
ScriptRunner for JIRA
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.ofbiz.OfBizDelegator
import groovy.sql.GroovyRowResult
import groovy.sql.Sql
import org.ofbiz.core.entity.ConnectionFactory
import org.ofbiz.core.entity.DelegatorInterface
import java.sql.Connection
select("select ...")
def select(String query){
OfBizDelegator delegator = ComponentAccessor.getOfBizDelegator();
DelegatorInterface delegatorInterface = delegator.getDelegatorInterface();
String helperName = delegatorInterface.getGroupHelperName("default");
Connection connection = ConnectionFactory.getConnection(helperName);
Sql sql = new Sql(connection);
List<GroovyRowResult> resultRows = []
try{
resultRows.addAll(sql.rows(query));
} finally {
//sql.close()
connection.close()
}
return resultRows
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment