| Geronimo_MoinMoin_wiki > OpenJCA |
OpenJCA is a JCA JDBC Implementation.
NOTE: Unless stated otherwise, it's assumed the commands are performed from openjca directory.
META-INF/geronimo-ra.xml for PetStore that sets up a datasource to HSQL database with sa as a username and empty password. The name of the datasource is petstoredb:
<?xml version="1.0" encoding="UTF-8"?>
<connector xmlns="http://org.apache.geronimo/xml/ns/j2ee"
xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
xsi:SchemaLocation="http://org.apache.geronimo/xml/ns/j2ee geronimo-connector_1_5.xsd">
<resourceadapter>
<outbound-resourceadapter>
<connection-definition>
<connectionfactory-interface>javax.sql.DataSource</connectionfactory-interface>
<name>petstoredb</name>
<config-property-setting name="DefaultUserName" >sa</config-property-setting>
<config-property-setting name="DefaultPassword" ><!-- empty --></config-property-setting>
<config-property-setting name="JdbcDriver" >org.hsqldb.jdbcDriver</config-property-setting>
<config-property-setting name="JdbcUrl" >jdbc:hsqldb:.</config-property-setting>
<connectionmanager-factory>
<connectionmanagerfactory-descriptor>org.apache.geronimo.connector.outbound.ConnectionManagerDeployment</connectionmanagerfactory-descriptor>
<config-property-setting name="UseConnectionRequestInfo">false</config-property-setting>
<config-property-setting name="UseSubject">false</config-property-setting>
<config-property-setting name="UseTransactionCaching">true</config-property-setting>
<config-property-setting name="UseTransactions">true</config-property-setting>
<config-property-setting name="UseLocalTransactions">true</config-property-setting>
<config-property-setting name="MaxSize">100</config-property-setting>
<config-property-setting name="BlockingTimeout">5000</config-property-setting>
<config-property-setting name="Name">petstoredb</config-property-setting>
</connectionmanager-factory>
</connection-definition>
</outbound-resourceadapter>
</resourceadapter>
</connector>
Using the datasource in an application boils down to declare the name of that datasource in Geronimo deployment descriptor, i.e. META-INF/geronimo-ejb-jar.xml for EJBs and WEB-INF/geronimo-web.xml for WARs.
<resource-ref>
<description>Allow the Fast Lane Reader Pattern to Read Catalog Data Directly via JDBC in the Web Tier</description>
<res-ref-name>jdbc/CatalogDB</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
<jndi-name>geronimo.management:j2eeType=JCAManagedConnectionFactory,name=petstoredb</jndi-name>
</resource-ref>
<datasource-name>petstoredb</datasource-name>
geronimo.management j2eeType=ConnectionManager,name=petstoredb j2eeType=JCAManagedConnectionFactory,name=petstoredb