1、websphere数据源获取方式:
在web.xml加入数据源的引用,如(OracleDS数据源):
<resource-ref id="OracleDS_ResourceRef">
<res-ref-name>OracleDS</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
<res-sharing-scope>Shareable</res-sharing-scope>
</resource-ref>
配置hibernate的数据源属性(一定得以java:comp/env方式引用数据源):
<bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName">
<value>java:comp/env/OracleDS</value>
</property>
</bean>
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource">
<ref bean="dataSource"/>
</property>
<property name="configLocation">
<value>
classpath:com/hc360/mmt/db/cfg/topicdb.cfg.xml
</value>
</property>
</bean>
2、如果在运行中出现错误,一般情况下都是因为jar包的原因,要不少包,要不包的版本不对。我在实际应用中,发现使用Hibernate的createQuery老是通不过,发现原来是少了antlr.jar包。
在web.xml加入数据源的引用,如(OracleDS数据源):
<resource-ref id="OracleDS_ResourceRef">
<res-ref-name>OracleDS</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
<res-sharing-scope>Shareable</res-sharing-scope>
</resource-ref>
配置hibernate的数据源属性(一定得以java:comp/env方式引用数据源):
<bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName">
<value>java:comp/env/OracleDS</value>
</property>
</bean>
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource">
<ref bean="dataSource"/>
</property>
<property name="configLocation">
<value>
classpath:com/hc360/mmt/db/cfg/topicdb.cfg.xml
</value>
</property>
</bean>
2、如果在运行中出现错误,一般情况下都是因为jar包的原因,要不少包,要不包的版本不对。我在实际应用中,发现使用Hibernate的createQuery老是通不过,发现原来是少了antlr.jar包。