MySQL FAQ

|  |  |  | FAQ MySQL FAQ |

Main
Welcome!
Download
Mailing Lists
The Team

Users
Quickstart
Hello World!
CMP Example
CMP Guide
Deploy
Startup
Validation
Configuration
Support
Request Feature
FAQ

Servers
Local Server
Remote Server
Tomcat

Integrators
Why OpenEJB
Overview
Design
Specification
Presentation

Developers
Custom Services
Release Plan
Source Code
SourceForge

MySQL FAQ

- How do I setup OpenEJB to use MySQL?
- Where can i get the MySQL JDBC driver?

## How do I setup OpenEJB to use MySQL?

Here are my config files for getting the CMP entity example to work. Note that the mm driver is no longer available from sourceforge and must now be directly downloaded from www.mysql.com and that the driver name has changed. The config files below use the new driver pacakge/name and work with MySQL 4.0.3 beta on Windows2000.

The SQL statement used to create the employee table was:

create table employee ( id integer primary key auto_increment, first_name varchar(15), last_name varchar(15), email varchar(30) );

openejb.conf

    <?xml version="1.0"?>

    <openejb>
      <Container id="Default CMP Container" ctype="CMP_ENTITY">
        Global_TX_Database c:/java/j2ee/openejb/hello_world_cmp/conf/hello.cmp_global_database.xml
        Local_TX_Database  c:/java/j2ee/openejb/hello_world_cmp/conf/hello.cmp_local_database.xml
      </Container>
      <Deployments jar="c:/java/j2ee/openejb/hello_world_cmp/employee.jar"/>
      <Connector id="Default JDBC Database">
        JdbcDriver  com.mysql.jdbc.Driver
        JdbcUrl     jdbc:mysql://localhost/openejb_cmp_example
        UserName    cso4309
        Password
      </Connector>
      <SecurityService id="Default Security Service"/>
      <TransactionService id="Default Transaction Manager"/> </openejb>

hello.cmp_global_database.xml

    <?xml version="1.0"?>

    <database name="Global_TX_Database" engine="mysql">
        <jndi name="java:comp/env/jdbc/openejb_cmp_example" />
        <mapping href="c:/java/j2ee/openejb/hello_world_cmp/conf/hello.cmp_or_mapping.xml" />
    </database>

hello.cmp_local_database.xml

    <?xml version="1.0"?>

    <database name="Local_TX_Database" engine="mysql" >

        <driver class-name="com.mysql.jdbc.Driver"
                url="jdbc:mysql://localhost/openejb_cmp_example">
          <param name="user"     value="cso4309" />
          <param name="password" value="" />
        </driver>

        <mapping href="c:/java/j2ee/openejb/hello_world_cmp/conf/hello.cmp_or_mapping.xml" />
    </database>

hello.cmp_or_mapping.xml

    <?xml version="1.0"?>

    <mapping>
      <class name="org.acme.employee.EmployeeBean" identity="id" key-generator="IDENTITY">
        <map-to table="employee"/>
        <field name="id" type="integer" direct="true">
          <sql name="id" type="integer"/>
        </field>
        <field name="firstname" type="string" direct="true">
          <sql name="first_name" type="varchar" dirty="check"/>
        </field>
        <field name="lastname" type="string" direct="true">
          <sql name="last_name" type="varchar" dirty="check"/>
        </field>
        <field name="email" type="string" direct="true">
          <sql name="email" type="varchar" dirty="check"/>
        </field>
      </class>
    </mapping>

## Where can i get the MySQL JDBC driver?

The mm driver is no longer available from sourceforge, the new driver is called Connector/J and must now be directly downloaded from www.mysql.com at http://www.mysql.com/downloads/api-jdbc-stable.html

Java, EJB, JDBC, JNDI, JTA, Sun, Sun Microsystems are trademarks or registered trademarks of Sun Microsystems, Inc. in the United States and in other countries. XML, XML Schema, XSLT and related standards are trademarks or registered trademarks of MIT, INRIA, Keio or others, and a product of the World Wide Web Consortium. All other product names mentioned herein are trademarks of their respective owners.