Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Hibernate Hibernate4 hibernate tomcat

Related Tutorials


 
 

Share on Google+Share on Google+

hibernate tomcat

Advertisement
In this section, you will learn about Hibernate datasource configuration in Tomcat.

hibernate tomcat

In this section, you will learn about Hibernate datasource configuration in Tomcat.

For Hibernate datasource configuration in Tomcat, you will need to take care the following things :

  • There will be no change in your hibernate.cfg.xml file.

  • Also the will be no change in web.xml and your <resource-ref> will be same as previous :
  • <resource-ref>
    <description>My DataSource</description>
    <res-ref-name>jdbc/primaryDB</res-ref-name>
    <res-type>javax.sql.DataSource</res-type>
    <res-auth>Container</res-auth>
    </resource-ref>
  • You need to edit context.xml situated inside $CATALINA_HOME/conf directory add the following Resource entry inside <context>:
  • <Resource name="jdbc/primaryDB" auth="Container" type="javax.sql.DataSource"
    maxActive="100" maxIdle="30" maxWait="10000"
    username="yourusername" password="yourpassword" driverClassName="com.mysql.jdbc.Driver"
    url="jdbc:mysql://localhost:3306/yourdatabase"/>
    
  • The resource name in the context.xml must match your reference name in the web.xml. This configuration tell to Tomcat environments about how to map resources from your deployment descriptor to the context.xml.
Advertisement

If you enjoyed this post then why not add us on Google+? Add us to your Circles



Liked it!  Share this Tutorial


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: May 31, 2012

Related Tutorials

Discuss: hibernate tomcat  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments:0
DMCA.com