Hi Guys,
I am trying to Run Select query on Database using Script Console. Script is fine but not sure why it's not giving result. Not giving any error when running script. Please suggest
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 cfname
FROM customfield
WHERE customfieldtypekey = 'com.atlassian.jira.plugin.system.customfieldtypes:select';
"""
Connection conn = ConnectionFactory.getConnection(helperName)
Sql sql = new Sql(conn)
try {
StringBuffer sb = new StringBuffer()
sql.eachRow(sqlStmt) { it ->
sb.append( it.getAt("cfname") )
sb.append('\n')
}
log.debug sb.toString()
}
finally {
sql.close()
}
Below Screenshot when running query on Local Database connection.
