Skip to content

Instantly share code, notes, and snippets.

@chuikoaleksandr
Created May 10, 2017 14:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chuikoaleksandr/da3d1d5c695abdf1043f3fab55e630cf to your computer and use it in GitHub Desktop.
Save chuikoaleksandr/da3d1d5c695abdf1043f3fab55e630cf to your computer and use it in GitHub Desktop.
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