Usage of the JNDI Report Source

The usage of a JNDI report source is very similar to using JDBC sources, the main difference is you don't need to stablish the driverClassName attribute.

Configuring the report source

The attributes required to be used with this type of data soruce are reflected in the following table:

AttributeOptionalDescription
valuefalseJNDI name of the data source
querytrueQuery to be used to offer the data to the report

Examples

Simple Usage

This usage of the report source will give to the report a java.sql.Connection instance. The report must be desgined with a default query.

The most simple usage consist on stablish the two required attributes:

<jr:source id="jndiSource"
        value="jdbc/databasename"
        type="jndi"
/>

Using queries

This kind of usage will give to the report a JasperReports' ResultSetDataSource instance. The report doesn't need to be designed with a default query.

To use queries with this kind of source you must include the query attribute:

<jr:source id="jndiSource" type="jndi"
        value="jdbc/databasename"
        query="select * from orders"
/>

Also you can use parametriced queries this way:

<jr:source id="jndiSource" type="jndi"
        value="jdbc/databasename"
        query="select * from orders where orderId = ?"
>
        <f:param value="23938" />
</jr:source>