This article carried: http://blog.chinaunix.net/u2/63740/showart_515514.html

1, in the context of context.xml inside tag add the following code:

<Resource name = "jdbc / mysql" auth = "Container"
type = "javax.sql.DataSource" driverClassName = "com.mysql.jdbc.Driver"
url = "jdbc: mysql: / / localhost: 3306/yourdbname"
username = "root"

password = "root"

maxActive = "20"

maxIdle = "10" />

2, in the web.xml in web-app add the following code under the

<resource-ref>
<description> MySql DataSource </ description>
<res-ref-name> jdbc / yourdbname </ res-ref-name>
<res-type> javax.sql.DataSource </ res-type>
<res-auth> Container </ res-auth>
</ resource-ref>

3. SPRING at the configuration file add the following code

<bean>
<property name="jndiName">

<value> java: comp / env / jdbc / yourdbname </ value>

</ property>
</ bean>

4. Finally SPRING in your configuration file add the following code to take over the configuration of HIBERNATE

<beans>
<bean>
<property name="dataSource" ref="dataSource"/>
<property name="mappingResources">
<list>
<value> here are loaded HIBERNATE OR document </ value>
</ list>
</ property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">

org.hibernate.dialect.MySQLInnoDBDialect

</ prop>

</ props>

</ property>

</ bean>

</ beans>