
24

Configure a DataSource for MySQL and TomEE tutorial
source link: https://marco.dev/2013/03/25/configure-a-datasource-for-mysql-and-tomee/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

java-version.com: What's new in Java 16? 15? Keep up to date!
Configure a DataSource for MySQL and TomEE tutorial
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 ?
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK