The JNDI data source accesses a database connection that is previously defined in the application server and published as a JNDI resource or service. Instead of specifying a driver and database as you do with JDBC data sources, you only need to specify the JNDI service name in your application server.
| Application servers use JDBC connections themselves to expose a database through JNDI. You must specify the JNDI service name of a JDBC connection. Your application server must also have the appropriate JDBC drivers and be configured to use them. |
For information about setting up a JNDI connection in your application server, see the following sections:
To create a JNDI data source:
| 1. | Log on as an administrator. |
| 2. | Click View > Repository, expand the folder tree, and right-click a folder to select Add Resource > Data Source from the context menu. Alternatively, you can select Create > Data Source from the main menu on any page and specify a folder location later. If you installed the sample data, the suggested folder is Data Sources. |
The New Data Source page appears.
| 3. | In the Type field, select JNDI Data Source. |
The information on the page changes to reflect what’s needed to define a JNDI data source.
| 4. | Fill in the required fields, along with any optional information. |
The service name is the name that the application server exposes through JNDI. The following figure shows values for connecting to the JNDI service for the Foodmart database included in the sample data.
|
JNDI Data Source Page |
| Set the Time Zone field when the date-time values stored in the target RDBMS do not indicate a time zone. When date-time values are stored in a format other than local time zone offset relative to Greenwich Mean time (GMT), you must specify a time zone so that the server can convert date-time values read from the target database properly. Set the Time Zone field to the correct time zone for the data in the data base. The list of available time zones is configurable, as described in Specifying Additional Time Zones. When in doubt, leave the Time Zone field blank. |
| 5. | Click Test Connection to validate the data source. If the validation fails, ensure that the values you entered are correct, that the database is exposed through JNDI, and that the database is running. Also, see the troubleshooting section JNDI Services on Apache Tomcat. |
| 6. | When the test is successful, click Save. The data source appears in the repository. |
For details about configuring and exposing a JNDI database connection at the application server level, refer to the documentation provided with your application server.
Recommended Comments
There are no comments to display.