Configure hibernate to connect to database via JNDI Datasource

后端 未结 4 1936
清酒与你
清酒与你 2020-11-27 12:29

Hi all I\'m using Hibernate+Struts2+Tomcat6+Mysql as my J2EE framework. I\'ve been using hibernate\'s built-in connection pooling mechanism but it turned out to be problemat

4条回答
  •  余生分开走
    2020-11-27 13:06

    Tomcat-7 JNDI configuration:

    Steps:

    1. Open the server.xml in the tomcat-dir/conf
    2. Add below tag with your DB details inside
    
    
    1. Save the server.xml file
    2. Open the context.xml in the tomcat-dir/conf
    3. Add the below inside the tag.
    
    
    1. Save the context.xml
    2. Open the hibernate-cfg.xml file and add and remove below properties.
    Adding:
    -------
    java:comp/env/jdbc/mydb
    
    Removing:
    --------
    
    
    
    
    1. Save the file and put latest .WAR file in tomcat.
    2. Restart the tomcat. the DB connection will work.

提交回复
热议问题