Skip to content

Instantly share code, notes, and snippets.

@seycileli
Created January 13, 2020 00:43
Show Gist options
  • Save seycileli/baa63b2fd3e071aea92b990fc75140ff to your computer and use it in GitHub Desktop.
Save seycileli/baa63b2fd3e071aea92b990fc75140ff to your computer and use it in GitHub Desktop.
MySQL & Hibernate in persistence.xml
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<persistence xmlns="http://xmlns.jcp.org/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence
http://xmlns.jcp.org/xml/ns/persistence/persistence_2_2.xsd"
version="2.2">
<persistence-unit name="org.hibernate.example.jpa" transaction-type="RESOURCE_LOCAL">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<class>org.packagename.classname</class> <!-- add each new created package name below this -->
<properties>
<property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost:3306/DbNameHere"/>
<property name="javax.persistence.jdbc.user" value=" "/> <!-- username here, default is 'root' -->
<property name="javax.persistence.jdbc.driver" value="org.mysql.jdbc.Driver"/>
<property name="javax.persistence.jdbc.password" value=" "/> <!-- password goes here -->
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect"/>
<property name="hibernate.show_sql" value="true"/>
<property name="hibernate.hbm2ddl.auto" value="create"/>
</properties>
</persistence-unit>
</persistence>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment