Friday, December 19, 2008

How to connect Tomcat 6 with JTOM 2.0.10 and MySql 5.1

I have tried to use Tomcat 6 with JTOM 2.0.10 and MySql 5.1 , but I it was unsuccesful, so then I tried to use another Transaction Manager, Atomikos, I find the docs and examples, but the example uses a Derby Database.

So I post how I've connected the MySql database using Atomikos and Tomcat 6:

Please follow the intructions that are posted here http://www.atomikos.com/Documentation/Tomcat6Integration33.

For the Web app please use the followin configuration in your WebApp Context File


Change the XA connection Properties according to your environment!!!

<?xml version="1.0" encoding="UTF-8"?>
<Context path="/dbtest" docBase="dbtest.war"
reloadable="true" crossContext="true">
<!-- Resource configuration for JDBC datasource-->
<Resource
name="jdbc/myDB"
auth="Container"
type="com.atomikos.jdbc.AtomikosDataSourceBean"
factory="com.atomikos.tomcat.BeanFactory"
uniqueResourceName="jdbc/myDB"
xaDataSourceClassName="com.mysql.jdbc.jdbc2.optional.MysqlXADataSource"
xaProperties.databaseName="test"
xaProperties.serverName="localhost"
xaProperties.port="3306"
xaProperties.user="USER"
xaProperties.password="PASSWORD"
xaProperties.url="jdbc:mysql://localhost:3306/test"
/>
</Context>


See you!

No comments: