participate


Enterprise JavaBeans - CMP using JBOSS and MySQL
<<   Back to Forum  |   Give us Feedback
This topic has 3 replies on 1 page.
PieterPareit
Posts:55
Registered: 1/22/04
CMP using JBOSS and MySQL   
Dec 5, 2004 7:28 AM

 
Hi,

I have a working CMP bean that uses the HyperSonic DB. Now I want that bean to work with a MySQL database, but with no success.

The things that I have done

1) Created a mysql-ds.xml in the deploy directory of my server

<?xml version="1.0" encoding="UTF-8"?>
<datasources>
<local-tx-datasource>
<jndi-name>MySqlDS</jndi-name>
<connection-url>jdbc:mysql://localhost:3306/hotline</connection-url>
<driver-class>com.mysql.jdbc.Driver</driver-class>
<user-name>root</user-name>
<password></password>
<min-pool-size>5</min-pool-size>
<max-pool-size>20</max-pool-size>
<idle-timeout-minutes>0</idle-timeout-minutes>
<track-statements>true</track-statements>
<security-domain></security-domain>
</local-tx-datasource>
</datasources>

2) Add the mysql-jdbc2-service.xml file into the deploy\jms directory
3) remove the hsqldb-jdbc2-service.xml from the deploy\jms directory

4) changed my ebj-jar
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE ejb-jar PUBLIC
"-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 1.1//EN"
"http://java.sun.com/j2ee/dtds/ejb-jar_1_1.dtd">


<ejb-jar>
<display-name>Initialen</display-name>

<enterprise-beans>
<entity>
<description>Encapsulates a User</description>
<ejb-name>Initiaal</ejb-name>
<home>hotline.beheerhotline.basisbestanden.initialen.InitialenHomeRemote</home>
<remote>hotline.beheerhotline.basisbestanden.initialen.InitialenRemote</remote>
<ejb-class>hotline.beheerhotline.basisbestanden.initialen.InitialenBean</ejb-class>
<persistence-type>Container</persistence-type>
<prim-key-class>java.lang.Integer</prim-key-class>
<reentrant>False</reentrant>

<abstract-schema-name>initialen</abstract-schema-name>
<cmp-field><field-name>initiaal</field-name></cmp-field>
<cmp-field><field-name>naam</field-name></cmp-field>
<cmp-field><field-name>dienst</field-name></cmp-field>
<cmp-field><field-name>email</field-name></cmp-field>
<cmp-field><field-name>telefoon</field-name></cmp-field>
<cmp-field><field-name>id</field-name></cmp-field>
<cmp-field><field-name>lockindicator</field-name></cmp-field>
<primkey-field>id</primkey-field>

</entity>
</enterprise-beans>

<assembly-descriptor>
<container-transaction>
<method>
<ejb-name>Initiaal</ejb-name>
<method-name>*</method-name>
</method>
<trans-attribute>Required</trans-attribute>
</container-transaction>
</assembly-descriptor>


</ejb-jar>

5) Changed my jbosscmp-jdbc.xml file

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE jbosscmp-jdbc PUBLIC "-//JBoss//DTD JBOSSCMP-JDBC 3.2//EN"
"http://www.jboss.org/j2ee/dtd/jbosscmp-jdbc_3_2.dtd">

<jbosscmp-jdbc>

<defaults>
<datasource>java:/MySqlDS</datasource>
<datasource-mapping>mySQL</datasource-mapping>
<create-table>true</create-table>
<remove-table>true</remove-table>
</defaults>

<enterprise-beans>
<entity>
<ejb-name>Initiaal</ejb-name>
<table-name>initialen</table-name>
<cmp-field>
<field-name>initiaal</field-name>
<column-name>initiaal</column-name>
</cmp-field>
<cmp-field>
<field-name>naam</field-name>
<column-name>naam</column-name>
</cmp-field>
<cmp-field>
<field-name>dienst</field-name>
<column-name>dienst</column-name>
</cmp-field>
<cmp-field>
<field-name>email</field-name>
<column-name>email</column-name>
</cmp-field>
<cmp-field>
<field-name>telefoon</field-name>
<column-name>telefoon</column-name>
</cmp-field>
<cmp-field>
<field-name>id</field-name>
<column-name>id</column-name>
</cmp-field>
<cmp-field>
<field-name>lockindicator</field-name>
<column-name>lockindicator</column-name>
</cmp-field>
</entity>
</enterprise-beans>
</jbosscmp-jdbc>

6) my jboss.xml file is the same as with the hypersonic db

<jboss>
<enterprise-beans>
<entity>
<ejb-name>Initiaal</ejb-name>
<jndi-name>InitialenBean</jndi-name>
</entity>
</enterprise-beans>
</jboss>

Result

When run my servlet to create a new instance of the bean, the data is still saved in the hypersonic DB and not in my mySQL database. I'm sure my mysql-ds.xml is right because JBoss made a two "working" tables into the database (jms_messages, jms_transactions)

I would be grate if somebody knows where I'm wrong,
thx Pieter
 
brunocollet
Posts:42
Registered: 5/14/04
Re: CMP using JBOSS and MySQL   
Dec 5, 2004 3:06 PM (reply 1 of 3)  (In reply to original post )

 
Hi,
I have gone through the JBoss/MySQL integration a few months ago. I have tried to document the steps involved on my website.
Feel free to comment so I can improve the document.
 
brunocollet
Posts:42
Registered: 5/14/04
Re: CMP using JBOSS and MySQL   
Dec 5, 2004 3:12 PM (reply 2 of 3)  (In reply to #1 )

 
Sorry I forgot the website URL:
http://www.practicalsoftwarearchitect.com
 
papaoso
Posts:2
Registered: 6/9/05
Re: CMP using JBOSS and MySQL   
Jun 28, 2005 11:01 AM (reply 3 of 3)  (In reply to original post )

 
Hi there,
I'm having the same error that you got, I'm using Oracle instead of Mysql but I think that is not problem, Please, Could you tell me what you did for solve this problem ?
Thanks a lot.
 
This topic has 3 replies on 1 page.
Back to Forum
 
Read the Developer Forums Code of Conduct

Click to email this message Email this Topic

Edit this Topic
  
 
 
Forums Statistics
    Users Online : 24
  • Guests : 127

About Sun forums
  • Sun Forums is a large collection of user generated discussions. It is here to help you ask questions, find answers, and participate in discussions.

    Check out our guide on Getting started with Sun Forums for a full walkthrough of how to best leverage the benefits of this community.

Powered by Jive Forums