One way I know to configure DB in JBOSS FUSE is to use blueprint.xml. Below configuration in blueprint.xml works
<bean id="gemsDataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<property name="driverClassName" value="oracle.jdbc.driver.OracleDriver" />
<property name="url" value="${gems_url}" />
<property name="username" value="${gems_username}" />
<property name="password" value="${gems_password}" />
<property name="maxIdle" value="5" />
<property name="minIdle" value="1" />
<property name="initialSize" value="1" />
</bean>
However, Is there any way to configure it in JBOSS container specific configuration file. For example - In JBOSS EAP we can configure it in standalone.xml. On similar lines can we configure it in JBOSS FUSE?
Jboss Fuse provides the integration with various data sources. You need to configure them bundle wise like you have used. But no such configuration is there on container level.
You can define a Datasource in a bundle and export it. In other bundles you import and use it like a service.
Prerequisites
Install these features
Datasource bundle
Drop an XML file inside deploy folder with following content:
This will export a service with
javax.sql.DataSource
interface and a JNDI nameUse Datasource service
When a bundle needs the datasource, ask OSGi to inject it.
The right Datasource is retrieved using the JNDI name you provided.
Using
availability="mandatory"
you can force your bundle to wait for the Datasource to become available. The bundle won't start without this reference.You need the correct JDBC drivers for the database you are using.
Other goodies
You have a lot of commands in JBoss Fuse console to interact with the database now, like
jdbc:datasources
that will list all available datasources. Withjdbc:query
you can run any SQL against your DB (good for debugging issues and testing the connection)