Announcement Announcement Module
Collapse
No announcement yet.
using datasourceUtils Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • using datasourceUtils

    I am using jasperreports for which I need a connection for which I am using DatasourceUtils

    Here is my code , this code uses same approach of opening connection try catch and finally release connection

    Code:
    		Connection con = DataSourceUtils.getConnection(dataSource);
    		try {
    			return JasperFillManager.fillReport(sourceFileName, parameters, con);
    		} catch (Exception e) {
    			DataSourceUtils.releaseConnection(con, dataSource);
    			con = null;
    			throw new RuntimeException(e);
    		}
    		finally {
    			DataSourceUtils.releaseConnection(con, dataSource);
    		}
    can I avoid this code and let spring handle closing connection automatically ?
Working...
X