Bug 157453 connections not released running report with parameters
Running a report with dynamic parameters (combo filled with db query) there are a lot connections that aren't released after execution. These connections are used to fill combo box with data from db. This causes reaching max connection limit on db (Oracle 9) I see that in class BirtViewerReportService there are some methods that create a task of type IGetParameterDefinitionTask but they never close it. I.e. public Collection getParameterSelectionList( IViewerReportDesignHandle design, InputOptions runOptions, String paramName ) throws ReportServiceException { /**** TASK CREATION ****/ IGetParameterDefinitionTask task = getParameterDefinitionTask( design, runOptions ); ViewerAttributeBean bean = getViewerAttrBean( runOptions ); if ( bean != null ) task.setParameterValues( bean.getParameters( ) ); /**** TASK EXECUTION ****/ /**** EXTRACT COMBO DATA ****/ Collection selectionList = task.getSelectionList( paramName ); /**** CONNECTION LOST TASK NEVER CLOSED ****/ return convertEngineParameterSelectionChoice( selectionList ); } I don't know if closing these tasks is the right thing. I try to close the task inside the task itself in method public Collection getSelectionList( String name ) ... if ( DesignChoiceConstants.PARAM_VALUE_TYPE_DYNAMIC .equals( selectionType ) ) { try { if (parameter.getDataSetName() != null) { return getChoicesFromParameterQuery(parameter); } else if (isCascadingParameter(parameter)) { Object[] parameterValuesAhead = getParameterValuesAhead(parameter); return getChoicesFromParameterGroup(parameter, parameterValuesAhead); } } finally { close(); } } ... and it's working for my reports (without any loose of connections and any performance decrease) Thanks! PS: note that with reports without parameters there are no problems
viewer/org.eclipse.birt.report.viewer/birt/WEB-INF/classes/org/eclipse/birt/report/service/BirtViewerReportService.java
ParameterGroupDefinition paramGroup = new ParameterGroupDefinition(
				name, displayName, promptText, null, cascade, helpText );
		List contents = convertParametersInGroup( engineParam.getContents( ),
				paramGroup, task );
		paramGroup.setParameters( contents );
		return paramGroup;
	}
	private static ParameterDefinition convertScalarParameter(
			IScalarParameterDefn engineParam, ParameterGroupDefinition group,
			IGetParameterDefinitionTask task )
	{
		Object handle = engineParam.getHandle( );
		ScalarParameterHandle scalarParamHandle = null;
		if ( handle instanceof ScalarParameterHandle )
			scalarParamHandle = (ScalarParameterHandle) handle;
		String name = engineParam.getName( );
		String pattern = scalarParamHandle == null ? "" : scalarParamHandle 
				.getPattern( );
		String displayFormat = engineParam.getDisplayFormat( );
		String displayName = engineParam.getDisplayName( );
		String helpText = engineParam.getHelpText( );
		String promptText = engineParam.getPromptText( );
		int dataType = engineParam.getDataType( );
		int controlType = engineParam.getControlType( );
		boolean hidden = engineParam.isHidden( );
		boolean allowNull = engineParam.allowNull( );
		boolean allowBlank = engineParam.allowBlank( );
		boolean mustMatch = scalarParamHandle == null
				? false
				: scalarParamHandle.isMustMatch( );