Getting a database connection for JDBC calls
It is not always feasible to use OfBizDelegator to get all the details that we need. What if we need to execute a complex query in the database via JDBC? In this recipe, we will see how we can retrieve the database connection that is defined in entityengine.xml.
How to do it...
The database connection lookup in JIRA is pretty simple and can be done in a single line in JIRA 7.x+. Just do the following:
Connection conn = new DefaultOfBizConnectionFactory().getConnection();
Simple, isn't it?
DataSourceInfo can be accessed as follows:
DatasourceInfo datasourceInfo = new DefaultOfBizConnectionFactory().getDatasourceInfo();
Over to you to write the JDBC calls wisely!