I want to use Microsoft SQL DB in my bundle, and need to load entities. I have 2 bundles, one for datasource and another one for loading entities. How to set the MSSQl datasource?
It is my datasource,
<bean id="esbDataSource" class="net.sourceforge.jtds.jdbcx.JtdsDataSource">
<property name="url" value="jdbc:sqlserver://localhost:1433;databaseName=testdb"/>
<property name="username" value="sa"/>
<property name="password" value="root"/>
</bean>
<osgi:reference id="platformTxManager" interface="org.springframework.transaction.PlatformTransactionManager"/>
<osgi:reference id="recoverableTxManager" interface="org.apache.geronimo.transaction.manager.RecoverableTransactionManager"/>
<!--<osgi:service id="pool" ref="datasourcePool" interface="javax.sql.DataSource" >
<entry key="osgi.jndi.service.name" value="jdbc/datasourcePool" />
</osgi:service>-->
<osgi:service ref="esbDataSource">
<osgi:interfaces>
<value>javax.sql.DataSource</value>
</osgi:interfaces>
<service-properties>
<entry key="osgi.jndi.service.name" value="jdbc/mssqlDatasource" />
</service-properties>
</osgi:service>
Persistence.xml
<persistence-unit name="billing" transaction-type="JTA">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<jta-data-source>osgi:service/javax.sql.DataSource/(osgi.jndi.service.name=jdbc/mssqlDatasource)</jta-data-source>
<class>org.redhat.support.entity.Billing</class>
<class>org.redhat.support.entity.Testing</class>
<exclude-unlisted-classes>true</exclude-unlisted-classes>
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.SQLServerDialect"/>
<property name="hibernate.hbm2ddl.auto" value="update"/>
<property name="hibernate.default_schema" value="testdb"/>
<property name="hibernate.show_sql" value="true"/>
</properties>
</persistence-unit>
Pom.xml
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>sqljdbc4</artifactId>
<version>4.0</version>
</dependency>
<dependency>
<groupId>net.sourceforge.jtds</groupId>
<artifactId>jtds</artifactId>
<version>1.3.0</version>
</dependency>
I want to deploy this in OSGi karaf container, what settings i missed?
Finally i got created tables and working fine. The below datasource is working fine. Please double check needed dependencies should be installed in JBoss Fuse karaf OSGi container.