我想在我的捆绑包中使用Microsoft SQL DB,并且需要加载实体。 我有2个捆绑包,一个用于数据源,另一个用于加载实体。 如何设置MSSQl数据源?
这是我的数据源,
<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>
我想在OSGi karaf容器中部署这个,我错过了哪些设置?
答案 0 :(得分:0)
最后我创建了表并且工作正常。以下数据源工作正常。 请仔细检查是否应在JBoss Fuse karaf OSGi容器中安装所需的依赖项。
<bean id="esbDataSource" class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName" value="net.sourceforge.jtds.jdbc.Driver"/>
<property name="url" value="jdbc:jtds:sqlserver://localhost:1433;databaseName=testdb"/>
<property name="username" value="sa"/>
<property name="password" value="root"/>
</bean>