Setting up your project
The topic of JNDI can be quite overwhelming to the uninitiated, and so we begin this chapter with a simple example to properly demonstrate Tomcat's JNDI support. We'll use JNDI to obtain a javax.sql.DataSource
that can be used to access a database, as well as to obtain an environment variable that is configured into the container.
In order to access a database, we first need a database to access, so our first order of business will be to install some additional software.
Installing MySQL
Note
If you already have MySQL or other database software installed, you can omit this installation step.
To install the MySQL database server, first download the appropriate binary distribution for your operating system from http://dev.mysql.com/downloads/mysql/5.1.html#downloads. The Essentials version of MySQL has all the functionality that we will need for this example. For 64-bit Vista, this file is named mysql-essential-5.1.37-win32.msi
.
Once the installation has completed, run...