Crystal Reports 10
Configuring JDBC (JNDI) Connectivity
Overview
This technical brief discusses configuring JDBC (JNDI) connectivity in Crystal Reports 10.
Contents
INTRODUCTION...... 2 BACKGROUND ...... 2 What is Java Database Connectivity?...... 2 What is Java Naming and Directory Interface?...... 2 How Crystal Reports works with JDBC (JNDI)...... 2 INITIAL CONFIGURATION ...... 3 THE CRDB_JAVASERVER.INI FILE ...... 3 PATH variable ...... 4 CLASSPATH variable...... 4 IORFileLocation variable...... 5 JDBC connection properties...... 5 JNDI connection properties...... 5 CONFIGURING CRYSTAL REPORTS FOR JDBC ...... 6 Specifying the path to the database JAR files ...... 6 Configuring JDBC in Crystal Reports...... 6 CONFIGURING CRYSTAL REPORTS FOR JNDI ...... 9 Configuring CRDB_JavaServer.ini for JNDI ...... 9 Configuring JNDI in Crystal Reports ...... 11 FINDING MORE INFORMATION ...... 14 Configuring Java Naming and Directory Interface (JNDI) on the Server- Side ...... 14 Configuring JNDI and JDBC Data Sources ...... 14
3/15/2005 9:54 AM Copyright © 2005 Business Objects. All rights reserved. Page 1 Crystal Reports 10 Configuring JDBC (JNDI) Connectivity
Introduction
This technical brief discusses how to configure the Crystal Reports Designer to use JDBC (JNDI) connectivity. JDBC (JNDI) connectivity is available in Crystal Reports 10 (and later) Professional, Developer, and Advanced editions, as well as in version 9.2 (and later) of the Crystal Reports Designer for Borland JBuilder and BEA WebLogic.
Background
What is Java Database Connectivity? Java Database Connectivity (JDBC) is the industry standard for database connectivity between the Java programming language and a wide range of databases and other tabular data sources, such as spreadsheets and flat files.
JDBC provides methods and properties that allow the Java language to perform SQL operations on the databases to which it connects. It is included in the J2SE (Java 2 Standard Edition) and J2EE (Java 2 Enterprise Edition) SDKs.
What is Java Naming and Directory Interface? The Java Naming Directory Interface (JNDI) provides an Application Programming Interface (API) that makes naming and directory functionality available to Java applications. For example, the API allows Java applications to access directory services as LDAP, NDS, DNS, and NIS. JNDI uses J2EE technologies to organize and locate components in a distributed computing environment.
For the purposes of this technical brief, JNDI refers to a type of data source. This data source is created on J2EE-compliant web application servers, and is used as a server-side connection to a specific database.
How Crystal Reports works with JDBC (JNDI) The Crystal Reports Designer uses a Java engine called the CRDBJavaServer to process Java-based requests.
CRDBJavaServer reads the CRDB_JavaServer.ini properties file to locate the Java SDK, the database drivers, and any other information that the Crystal Reports Designer requires to process the Java-based task.
After reading the properties file, the CRDBJavaServer creates temporary files (.ior files) that the Crystal Reports Designer uses to connect to the appropriate database.
NOTE CRDBJavaServer requires access to J2SE 1.4.x (and later).
3/15/2005 9:54 AM Copyright © 2005 Business Objects. All rights reserved. Page 2
cr10_configuring_JDBC_JNDI.pdf Crystal Reports 10 Configuring JDBC (JNDI) Connectivity
Initial Configuration
Before Crystal Reports is able to connect to a database, a JDBC (JNDI) connection must be configured as follows:
1. Download and install Sun JDK version 1.4.2 (or later) from the following location:
http://java.sun.com/j2se/
2. If you are using Crystal Reports 10, complete these steps to download and install the JDBC (JNDI) drivers (these drivers are not part of the Crystal Reports 10 product installation):
i. Click the following link and download the drivers:
Download Windows JDBC, XML and DB2 Unicode Drivers - all languages
ii. Extract the files to a temporary folder.
iii. Double-click the Setup.exe file and complete the installation steps.
3. Ensure that you have the corresponding JDBC database drivers on hand for the database and version that you are using. Where you place the database drivers on your computer depends on the connection type you are using.
The CRDB_JavaServer.ini File
Now that the initial configuration has been completed, the next step is to set up the CRDB_JavaServer.ini file. The CRDB_JavaServer.ini file is a configuration file that is needed by the Crystal Reports Designer to initialize the properties needed to use JDBC (JNDI) connectivity. In a default installation, this file is found at the following location:
C:\Program Files\common files\crystal decisions\2.5\bin
Here is a sample of the file contents, with the configurable portions of the file discussed in the following sections:
[Common] PATH = ${JAVA_HOME}/bin CLASSPATH = C:\Program Files\Common Files\Crystal Decisions\2.5\bin\CRDBJavaServer.jar;${CLASSPATH}
IORFileLocation = ${TEMP} JavaServerTimeout = 1800 JVMMaxHeap = 64000000 JVMMinHeap = 32000000
3/15/2005 9:54 AM Copyright © 2005 Business Objects. All rights reserved. Page 3
cr10_configuring_JDBC_JNDI.pdf Crystal Reports 10 Configuring JDBC (JNDI) Connectivity
[CRDB_JDBC] CacheRowSetSize = 100 JDBCURL = JNDIURL = JDBCUserName = JDBCDriverName = JNDIUserName = JNDIConnectionFactory = JNDIInitContext = GenericJDBCDriverBehavior = DB2
[CRDB_XML] PREREADNBYTE = 5000 CacheRowSetSize = 100 XMLLOCALURL = SCHEMALOCALURL = XMLHTTPURL = SCHEMAHTTPURL = USETEMPFile = TRUE
PATH variable PATH = ${JAVA_HOME}/bin
The PATH variable defines the path to the Java SDK you are using for the JDBC (JNDI) connection. By default, the PATH variable is set to ${JAVA_HOME}/bin.
CLASSPATH variable CLASSPATH = “C:\Program Files\Common Files\Crystal Decisions\2.5\bin\CRDBJavaServer.jar”;${CLASSPATH}
The CLASSPATH variable specifies the location of the CRDBJavaServer.jar file, database JAR files (required for JDBC connectivity), and the web application server JAR files (required for JNDI connectivity).
NOTE Enclose the path in double quotation marks if it contains spaces. If you have any issues when trying to create a JDBC or JNDI connection in Crystal Reports, verify that the physical paths are correct in the .ini file and the environment variables.
3/15/2005 9:54 AM Copyright © 2005 Business Objects. All rights reserved. Page 4
cr10_configuring_JDBC_JNDI.pdf Crystal Reports 10 Configuring JDBC (JNDI) Connectivity
IORFileLocation variable
IORFileLocation = ${TEMP}
The IORFileLocation variable defines the path to where the temporary files (.ior) are written. The .ior files are generated by the CRDBJavaServer to enable the Crystal Reports Designer to determine how to connect to the database. By default, the IORFileLocation variable is set to the same folder as the Temp environment variable. Ensure that .ior files are able to be written to this folder, otherwise, the JDBC (JNDI) connection will fail.
JDBC connection properties JDBCURL specifies the database provider URL for your database.