martedì 8 novembre 2011

Creating a new MySQL DS

Create a file in the deploy directory (eg. mysql-ds.xml) with a content like this:


<datasources>
    <local-tx-datasource>
        <jndi-name>SourceBoxDS</jndi-name>
        <connection-url>jdbc:mysql://localhost:3306/sourcebox</connection-url>
        <driver-class>com.mysql.jdbc.Driver</driver-class>
        <user-name>root</user-name>
        <password></password>
    </local-tx-datasource>
</datasources>


If JBossAS is running, in the console you will get:

15:17:06,859 INFO  [org.jboss.resource.connectionmanager.ConnectionFactoryBindingService] Bound ConnectionManager 'jboss.jca:service=DataSourceBinding,name=SourceBoxDS' to JNDI name 'java:SourceBoxDS'
It's clear from this log that now the db object is mapped in JNDI to the path "java:SourceBoxDS".
In order to use it in the entities definition you can set in the persistence.xml file this property:
 <jta-data-source>java:SourceBoxDS</jta-data-source>

Nessun commento:

Posta un commento