Tuesday, September 27, 2011

openEJB3 and MySQL DS Config

Configuration in openejb.xml (bundled in tomcat conf):

<Resource id="MySQL Database" type="DataSource">
#MySQL example
#
#This connector will not work until you download the driver at:
#http://www.mysql.com/downloads/api-jdbc-stable.html

JdbcDriver com.mysql.jdbc.Driver
JdbcUrl jdbc:mysql://localhost/iim
UserName
Password
</Resource>

The drive for MySQL is required by openEJB (should go into the tomcat lib, not the openEJB3 lib)

Before hibernate can be used, it need to be installed again into the tomcat lib.

persistence.xml:
<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
version="1.0">
<persistence-unit name="iimdb">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<jta-data-source>iimdb</jta-data-source>
<non-jta-data-source>iimdbNonJta</non-jta-data-source>
<properties>
<!-- this is to control the auto drop and create of schema -->
<property name="hibernate.hbm2ddl.auto" value="update" />
<property name="hibernate.show.sql" value="true"></property>
</properties>
</persistence-unit>
</persistence>

No comments:

Post a Comment