Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Add category link at the bottom of the page

...

In order to work through the two configurations, I've chosen to use the NetBeans Hibernate Tutorial. The original tutorial does not make any use of database pooling. Modifications to the tutorial will be shown below to use either Tomcat's database pooling via JNDI or Hibernate's provided CP30 C3P0 database pooling.

Preliminaries

...

No other connection or pooling information should be present in your hibernate.cfg.xml file. Note, you still need the database dialect properties in order for Hibernate to function.

If you are using Netbeans as your IDE, the hibernate.cfg.xml file will be found in <project-name>/src/java by default.

...

Do not also copy the JDBC driver jar to $CATALINA_HOME/lib.

Hibernate ships with the CP30 C3P0 connection pooling classes, so as long as the Hibernate jars are in WEB-INF/lib directory (which they should be), they should be available.

...

No Format
<!-- connection information -->
<property name="hibernate.connection.driver_class">
    com.mysql.jdbc.Driver
</property>
<property name="hibernate.connection.url">
    jdbc:mysql://localhost/sakila
</property>
<property name="hibernate.connection.username">******</property>
<property name="hibernate.connection.password">******</property>

<!-- database pooling information -->
<property name="connection_provider_class">
    org.hibernate.connection.CP30ConnectionProviderC3P0ConnectionProvider
</property>
<property name="c3p0.minPoolSize">5</property>
<property name="c3p0.timeout">1000</property>

...

  • Requires NO META-INF/context.xml information
  • Requires NO WEB-INF/web.xml information
  • Requires connection information to be in hibernate.cfg.xml
  • Requires pooling information to be in hibernate.cfg.xml
  • Requires MySQL connectors to be in WEB-INF/lib (ideally)
  • Requires the Hibernate jars to be in WEB-INF/lib

...

CategoryFAQ