Jump to content

Recommended Posts

Posted

Hi,

my subreport connects successfully to a different database, by the description of ntatlock.

Like:

<subreport>    <reportElement mode="Opaque" x="555" y="0" width="5" height="20"/>    <subreportParameter name="P_B">        <subreportParameterExpression><![CDATA[$F{username}]]></subreportParameterExpression>    </subreportParameter>    <connectionExpression><![CDATA[java.sql.DriverManager.getConnection($P{P_SUB_DATASOURCE}.getConnectionUrl(),$P{P_SUB_DATASOURCE}.getUsername(),$P{P_SUB_DATASOURCE}.getPassword())]]></connectionExpression>    <returnValue subreportVariable="V_M" toVariable="V_M"/>    <subreportExpression><![CDATA["repo:0001_Subreport.jrxml"]]></subreportExpression></subreport>[/code]

But the connection is not closing. So what can I do, to close the connection?

  • Replies 1
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

  • Solution
Posted

Found it!

<parameter name="P_SUB_DATASOURCE" class="com.jaspersoft.jasperserver.api.metadata.jasperreports.domain.JdbcReportDataSource" isForPrompting="false">    <defaultValueExpression><![CDATA[com.jaspersoft.jasperserver.api.engine.jasperreports.util.RepositoryUtil.getThreadRepositoryContext().getRepository().getResource(null,"/<path to data source>/")]]></defaultValueExpression></parameter>[/code]
<parameter name="P_SUB_CONNECTION" class="java.sql.Connection" isForPrompting="false">    <defaultValueExpression><![CDATA[java.sql.DriverManager.getConnection($P{P_SUB_DATASOURCE}.getConnectionUrl(),$P{P_SUB_DATASOURCE}.getUsername(),$P{P_SUB_DATASOURCE}.getPassword())]]></defaultValueExpression></parameter> [/code]
<subreport>    <reportElement mode="Opaque" x="555" y="0" width="5" height="20"/>    <subreportParameter name="P_B">        <subreportParameterExpression><![CDATA[$F{user}]]></subreportParameterExpression>    </subreportParameter>    <connectionExpression><![CDATA[$P{P_SUB_CONNECTION}]]></connectionExpression>    <returnValue subreportVariable="V_M" toVariable="V_M"/>    <subreportExpression><![CDATA["repo:0001_Subreport.jrxml"]]></subreportExpression></subreport>[/code]
<textField>    <reportElement x="555" y="10" width="5" height="20"/>    <textElement verticalAlignment="Middle"/>    <textFieldExpression><![CDATA[""; $P{P_SUB_CONNECTION}.close()]]></textFieldExpression></textField>[/code]

 

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...