On Tomcat 6.x, Hibernate 3.x, MySQL, and JNDI

After lots of googling and documentation reading, I got a setup of mine to work properly with Tomcat 6.x, Hibernate 3.x, MySQL, and JNDI datasources. For what its worth, most of the resources on the web regarding setting this up with the versions I specified are worthless. To save myself the future hassle, and the lot of you who might be having a hard time setting this up, here are the configuration files and directives required.



DB Connection jdbc/my_app javax.sql.DataSource Container


java:comp/env/jdbc/my_app org.hibernate.dialect.MySQLDialect thread </session-factory> </hibernate-configuration> ... You can get your session factory as usual: sessionFactory = new Configuration().configure().buildSessionFactory(); or whichever way you prefer.
Written on January 6, 2008