Sample persistence.xml that uses hibernate & mysql


/ Published in: Java
Save to your folder(s)



Copy this code and paste it in your HTML
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <persistence
  3. xmlns="http://java.sun.com/xml/ns/persistence"
  4. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  5. xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
  6. http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
  7. version="1.0">
  8. <persistence-unit name="<PERSISTENCE UNIT NAME>">
  9. <properties>
  10. <!--
  11. <property name="hibernate.ejb.cfgfile" value="/hibernate.cfg.xml"/>
  12. <property name="hibernate.hbm2ddl.auto" value="create"/>
  13. -->
  14. <property name="hibernate.archive.autodetection" value="class, hbm"/>
  15. <property name="hibernate.show_sql" value="true"/>
  16. <property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver"/>
  17. <property name="hibernate.connection.password" value="<PASSWORD>"/>
  18. <property name="hibernate.connection.url" value="jdbc:mysql://<HOST IP ADDRESS>/<DB NAME>"/>
  19. <property name="hibernate.connection.username" value="<USERNAME>"/>
  20. <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect"/>
  21. <property name="hibernate.c3p0.min_size" value="5"/>
  22. <property name="hibernate.c3p0.max_size" value="20"/>
  23. <property name="hibernate.c3p0.timeout" value="300"/>
  24. <property name="hibernate.c3p0.max_statements" value="50"/>
  25. <property name="hibernate.c3p0.idle_test_period" value="3000"/>
  26. </properties>
  27. </persistence-unit>
  28. </persistence>

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.