1343290 - How to use a JNDI data source with the Crystal Reports Java SDK on Tomcat

SAP Knowledge Base Article - Public

1343290 - How to use a JNDI data source with the Crystal Reports Java SDK on Tomcat

Symptom

How to configure the Crystal Reports Java SDK to use a JNDI data source when deployed on Tomcat?

Reproducing the Issue

  • Crystal Reports Java SDK
  • Crystal Reports for Eclipse 1
  • Crystal Reports for Eclipse 2

Resolution

Follow these instructions to add a JNDI resource to your web application for oracle on Tomcat.

Note that the JNDI name needs to be preceded by 'jdbc/'.

1. Add to your WEB-INF/web.xml (res-ref-name is your jndi name):

<resource-ref>
<description>DB Connection</description>
<res-ref-name>jdbc/oracle_jndi_conn</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>

2. Add to your META-INF/context.xml (modify connection url and username/password to reflect your system):

<Resource
name="jdbc/oracle_jndi_conn"
type="javax.sql.DataSource"
url="jdbc:oracle:thin:{userid}/{password}@10.180.131.203:20121:bo65maer"
driverClassName="oracle.jdbc.driver.OracleDriver"
username="system"
password="system"
maxActive="4"
maxIdle="2"
maxWait="5000"/>

3. For the crystal report, you will need the "Connection Name (Optional)" property when creating a JDBC connection for JNDI. This will enable JNDI lookup and will be used instead of the JDBC connection when the report is deployed to tomcat:

Connection Name (Optional): oracle_jndi_conn

There is no need to fill in the JNDI specific connection details, the only setting needed is "Connection Name (Optional)".

Note that in Crystal Reports, you do not precede the connection with "jdbc/" as you did in the context.xml and web.xml.

Keywords

KBA , BI-DEV , Business Intelligence Software Development Kits (SDKs) , How To

Product

Crystal Reports for Java 1.0