Created
May 10, 2017 14:42
-
-
Save chuikoaleksandr/da3d1d5c695abdf1043f3fab55e630cf to your computer and use it in GitHub Desktop.
ScriptRunner for JIRA
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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