Configure hibernate to connect to database via JNDI Datasource

后端 未结 4 1935
清酒与你
清酒与你 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:01

    Apparently, you did it right. But here is a list of things you'll need with examples from a working application:

    1) A context.xml file in META-INF, specifying your data source:

    
        
    
    

    2) web.xml which tells the container that you are using this resource:

    
        jdbc/DsWebAppDB
        javax.sql.DataSource
    
    

    3) Hibernate configuration which consumes the data source. In this case, it's a persistence.xml, but it's similar in hibernate.cfg.xml

    
        org.hibernate.ejb.HibernatePersistence
        
            
            
        
    
    

提交回复
热议问题