This article describes how to config jndi in tomcat6 and work with hibernate.
step 1) open file context.xml under folder %tomcat_home%/conf,
and add the following settings between <Context> and </Context>
<Resource name="jdbc/leave" auth="Container" type="javax.sql.DataSource"
password="lmsdb1234" username="lms" driverClassName="org.gjt.mm.mysql.Driver"
url="jdbc:mysql://localhost:3306/lmsdb" maxActive="20" maxIdle="1" maxWait="5000"/>
step 2) copy mysql driver file, e.g. mysql-connector-java-5.1.7-bin.jar to folder %tomcat_home%/lib
step 3) open file web.xml for leave project, and add the following settings
<resource-ref>
<description>MySQL DataSource</description>
<res-ref-name>jdbc/leave</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
make sure the refercence name is the same as defined in tomcat config file.
step 4) open hibernate config file and assign the jndi settings
<property name="connection.datasource">
java:/comp/env/jdbc/leave
</property>