To create a database pool in Geronimo, i need to write a mysql xml plan for Geronimo. Without this xml file, the pool could not be create. Below are the steps to follow to create the xml file.
Writing this plan is essential to connect to external database. This plan is to be go hand in hand with a file in geronimo repository. The path to the respository:
/home/chongming/geronimo-2.1/repository/org/tranql/tranql-connector-ra/1.3/tranql-connector-ra-1.3.rar
Firstly we need to download the mysql connector from:
Create folder under /home/chongming/geronimo-2.1/respository:
# mkdir mysql/mysql-connector-java/3.1.14-bin
Copy the sql-connector jar file into the directory
# cp mysql-connector-java /home/chongming/geronimo-2.1/respository/mysql/mysql-connector-java/3.1.14-bin
Below is an example of creating a mysql-geronimo-plan.xml file. Edit the file as necessary
In fact what i need to key in under the tags are:
- <config-property-setting name="UserName"> = Username of my database
- <config-property-setting name="Password"> = Password of my database
- <config-property-setting name="Driver"> = The driver for the database
- <config-property-setting name="ConnectionURL"> = The connection url for the apps to database
- <global-jndi-name> = The jndi for the database
========================================================
<?xml version="1.0" encoding="UTF-8"?>
<connector xmlns="http://geronimo.apache.org/xml/ns/j2ee/connector-1.2">
<dep:environment xmlns:dep="http://geronimo.apache.org/xml/ns/deployment-1.1">
<dep:moduleId>
<dep:groupId>user</dep:groupId>
<dep:artifactId>jdbcdatasource</dep:artifactId>
<dep:version>2.0</dep:version>
<dep:type>car</dep:type>
</dep:moduleId>
<dep:dependencies>
<dep:dependency>
<dep:groupId>mysql</dep:groupId>
<dep:artifactId>mysql-connector-java</dep:artifactId>
<dep:version>3.1.14-bin</dep:version>
<dep:type>jar</dep:type>
</dep:dependency>
</dep:dependencies>
</dep:environment>
<resourceadapter>
<outbound-resourceadapter>
<connection-definition>
<connectionfactory-interface>
javax.sql.DataSource
</connectionfactory-interface>
<connectiondefinition-instance>
<name>MusicDS</name>
<config-property-setting name="UserName">
chongming
</config-property-setting>
<config-property-setting name="Password">
password
</config-property-setting>
<config-property-setting name="Driver">
com.mysql.jdbc.Driver
</config-property-setting>
<config-property-setting name="ConnectionURL">
jdbc:mysql://localhost:3306/music
</config-property-setting>
<config-property-setting name="CommitBeforeAutocommit">
false
</config-property-setting>
<config-property-setting name="ExceptionSorterClass">
org.tranql.connector.NoExceptionsAreFatalSorter
</config-property-setting>
<connectionmanager>
<local-transaction/>
<single-pool>
<max-size>10</max-size>
<min-size>0</min-size>
<blocking-timeout-milliseconds>
5000
</blocking-timeout-milliseconds>
<idle-timeout-minutes>
30
</idle-timeout-minutes>
<match-one/>
</single-pool>
</connectionmanager>
<global-jndi-name>
jdbc/MusicDB
</global-jndi-name>
</connectiondefinition-instance>
</connection-definition>
</outbound-resourceadapter>
</resourceadapter>
</connector>
<connector xmlns="http://geronimo.apache.org/xml/ns/j2ee/connector-1.2">
<dep:environment xmlns:dep="http://geronimo.apache.org/xml/ns/deployment-1.1">
<dep:moduleId>
<dep:groupId>user</dep:groupId>
<dep:artifactId>jdbcdatasource</dep:artifactId>
<dep:version>2.0</dep:version>
<dep:type>car</dep:type>
</dep:moduleId>
<dep:dependencies>
<dep:dependency>
<dep:groupId>mysql</dep:groupId>
<dep:artifactId>mysql-connector-java</dep:artifactId>
<dep:version>3.1.14-bin</dep:version>
<dep:type>jar</dep:type>
</dep:dependency>
</dep:dependencies>
</dep:environment>
<resourceadapter>
<outbound-resourceadapter>
<connection-definition>
<connectionfactory-interface>
javax.sql.DataSource
</connectionfactory-interface>
<connectiondefinition-instance>
<name>MusicDS</name>
<config-property-setting name="UserName">
chongming
</config-property-setting>
<config-property-setting name="Password">
password
</config-property-setting>
<config-property-setting name="Driver">
com.mysql.jdbc.Driver
</config-property-setting>
<config-property-setting name="ConnectionURL">
jdbc:mysql://localhost:3306/music
</config-property-setting>
<config-property-setting name="CommitBeforeAutocommit">
false
</config-property-setting>
<config-property-setting name="ExceptionSorterClass">
org.tranql.connector.NoExceptionsAreFatalSorter
</config-property-setting>
<connectionmanager>
<local-transaction/>
<single-pool>
<max-size>10</max-size>
<min-size>0</min-size>
<blocking-timeout-milliseconds>
5000
</blocking-timeout-milliseconds>
<idle-timeout-minutes>
30
</idle-timeout-minutes>
<match-one/>
</single-pool>
</connectionmanager>
<global-jndi-name>
jdbc/MusicDB
</global-jndi-name>
</connectiondefinition-instance>
</connection-definition>
</outbound-resourceadapter>
</resourceadapter>
</connector>
Completing this xml file should able to create the pool once it is deploy into the app server
No comments:
Post a Comment