`
wanwok
  • 浏览: 30495 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

websphere 6.1 SQL2005 数据源老是资源报回滚

    博客分类:
  • J2EE
阅读更多
     以前没有接触过SSH的项目,现在要用,就是赶鸭子上阵,看了别人的一点源码就开始写东西。工程在tomcate5.0上一切都正常,数据源都可以使用,但是放在WAS上先是报警告,不允许直接使用资源。给websphere 6.1.0.0 升级到websphere 6.1.0.19就没警告了。现在的问题是每次访问数据库都是提示资源回滚,数据没法插、更新入到库里。网友都说是把setAutoCommit(true);设为true就可以了。另外写了一个工程,确实也是这样子。不过我的工程是用spring1.2+hibernate3.0写的。因为在spring里可以使用事务代理,我的工程里就没有手动的提交事务这一部代码。不知道有什么办法可以解决没有,现在不可能再给他们加上事务提交。下面给我的spring的配置文件,希望熟悉的兄弟帮忙看一下。
applicationContext.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">

<beans>	
	<bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
		<property name="jndiName">
			<value>jdbc/sysdb</value>
		</property>
	</bean>

	<bean id="sessionFactory"
		class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"> 
		<property name="dataSource">
			<ref bean="dataSource" />
		</property>
		<property name="mappingResources">
			<list>
				<value>
					com/sunyard/ispt/model/TableNotice.hbm.xml
				</value>
				<value>
					com/sunyard/ispt/model/TableMaterial.hbm.xml
				</value>
				<value>
					com/sunyard/ispt/model/TableQuestion.hbm.xml
				</value>					
				<value>com/sunyard/ispt/model/TableRule.hbm.xml
				</value>
				<value>com/sunyard/ispt/model/TablePaper.hbm.xml</value>
				<value>
					com/sunyard/ispt/model/TableResult.hbm.xml
				</value>
				<value>
					com/sunyard/ispt/model/TableConfig.hbm.xml
				</value>
				<value>com/sunyard/ispt/model/TablePower.hbm.xml</value>
				</list>
		</property>
		<property name="hibernateProperties">
			<props>
				<prop key="hibernate.dialect">
					org.hibernate.dialect.SQLServerDialect
				</prop>
				<prop key="hibernate.show_sql">true</prop>
				<prop key="hibernate.query.factory_class">
					org.hibernate.hql.classic.ClassicQueryTranslatorFactory
				</prop>
			</props>
		</property>
	</bean>	
	<!-- 配置使用Hibernate局部事务策略 -->
	<bean id="transactionManger"
		class="org.springframework.orm.hibernate3.HibernateTransactionManager">
		<property name="sessionFactory" ref="sessionFactory"></property>
	</bean>
	<!-- 配置一个事务拦截器 -->
	<bean id="transactionInterceptor"
		class="org.springframework.transaction.interceptor.TransactionInterceptor">
		<!-- 事务拦截器Bean需要依赖注入一个事务管理器 -->
		<property name="transactionManager" ref="transactionManger"></property>
		<property name="transactionAttributes">
			<!-- 下面定义事务传播属性 -->
			<props>	
				<prop key="insert*">PROPAGATION_REQUIRED</prop>			
			</props>
		</property>
	</bean>	
</beans>

web.xml
<resource-ref>
         <description>JNDI JDBC DataSource</description> 
         <res-ref-name>jdbc/sysdb</res-ref-name>         
         <res-type>javax.sql.DataSource</res-type>
	<res-auth>Container</res-auth>
</resource-ref>
分享到:
评论
3 楼 wanwok 2008-11-05  
哎,没法子。手动提交算了。
2 楼 wanwok 2008-11-05  
后台日志:
[08-11-5 14:49:06:171 CST] 0000002a LocalTranCoor W   WLTC0033W: 清除 LocalTransactionContainment 时,资源 sysdb 回滚。
[08-11-5 14:49:06:171 CST] 0000002a LocalTranCoor W   WLTC0032W: 清除 LocalTransactionContainment 期间回滚了一个或多个本地事务资源。
[08-11-5 14:49:07:234 CST] 0000002a LocalTranCoor W   WLTC0033W: 清除 LocalTransactionContainment 时,资源 sysdb 回滚。
[08-11-5 14:49:07:234 CST] 0000002a LocalTranCoor W   WLTC0032W: 清除 LocalTransactionContainment 期间回滚了一个或多个本地事务资源。
1 楼 wanwok 2008-10-30  
另外再问两个题外的问题:
    网友都说JDNI名字是写成:"java:comp/env/jdni名"的格式,但是我的工程里写成这样是提示找不到数据源的。不知道为什么。只好写成这样子    <value>jdbc/sysdb</value>
   还有就是记得在IBM网站上看到的一篇贴子中提到,<value>jdbc/sysdb</value>此处的JDNI的名字只要去web.xml中的相同就可以,可以不与WAS服务的数据源同名,或者不同。我试过,必须同名才可以访问。

  

相关推荐

Global site tag (gtag.js) - Google Analytics