Configure a DataSource for MySQL and TomEE tutorial
Updated: 2013-03-25
Copy the driver of MySql in the TomEE lib directory:

You have to modify the config file tomEE/conf/tomee.xml
In the file you have to add your mysql configuration:

<Resource id="pmone" type="DataSource"> JdbcDriver com.mysql.jdbc.Driver JdbcUrl jdbc:mysql://localhost:3306/pm UserName user Password secret JtaManaged true </Resource>
Your persistence xml has to use the datasource defined in tomee.xml (in this case ‘phone’)
<?xml version="1.0" encoding="UTF-8"?> <persistence version="2.0" xmlns="https://java.sun.com/xml/ns/persistence" xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="https://java.sun.com/xml/ns/persistence https://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"> <persistence-unit name="pmWebPU"> <jta-data-source>pmone</jta-data-source> <exclude-unlisted-classes>false</exclude-unlisted-classes> <properties> </properties> </persistence-unit> </persistence>
Done 🙂