0 Replies Latest reply on Jun 24, 2005 2:13 PM by Leos Urban

    EJB 3.0 Preview 5 and MySQL 4.1

    Leos Urban Newbie

      create datasource definition for you Mysql database
      - copy JDBC driver (for example mysql-connector-java-3.0.16-ga-bin.jar) to $JBOSSHOME/server/all/lib.
      - create your MYSQL database (for example with name "mytest")
      - create file mysqltest-ds.xml with content:

      <?xml version="1.0" encoding="UTF-8"?>
      <datasources>
       <local-tx-datasource>
       <jndi-name>MY_DS</jndi-name> <connection-url>jdbc:mysql://localhost:3306/mytest?autoReconnect=true&useUnicode=true&characterEncoding=UTF-8</connection-url>
       <driver-class>com.mysql.jdbc.Driver</driver-class>
       <user-name>root</user-name>
       <password>abcd</password>
       </local-tx-datasource>
      </datasources>
      

      Note: if I remember for using mysql 4.x you need remove useUnicode and characterEncoding from connection string. This will works with mysql 3.x.
      - copy this file to $JBOSSHOME/server/all/deploy

      Now Jboss knows new datasource named MY_DS.

      Specify datasource for your EJB3 package

      In EJB3 package (ejb3 extension) you then need to create META-INF folder and file "hibernate.properties" with content:
      hibernate.transaction.manager_lookup_class=org.hibernate.transaction.JBossTransactionManagerLookup
      hibernate.hbm2ddl.auto=create
      hibernate.cache.provider_class=org.hibernate.cache.HashtableCacheProvider
      hibernate.connection.datasource=java:/MY_DS
      hibernate.dialect=org.hibernate.dialect.MySQLDialect
      


      Hope it helps.

      Leonell