下一个帖子:
http://community.csdn.net/Expert/topic/5733/5733673.xml?temp=.8231012

解决方案 »

  1.   

    接上一个帖子:
    <property name="dataSource">
      <ref local="dataSourceDjk"/>
     </property>
     <property name="jtaTransactionManager">   
            <ref bean="jotm" />   
        </property> 
     <property name="lobHandler"><ref local="oracleLobHandler"/></property>
    </bean>
    <bean id="dataSourceCgk" class="org.enhydra.jdbc.pool.StandardXAPoolDataSource">
     <property name="dataSource"><ref local="innerDataSourceDjk"/></property>
     <property name="transactionManager"><ref local="jotm"/></property>
     <property name="maxSize"><value>10</value></property>
     <property name="user"><value>cgklogapp</value></property>
     <property name="password"><value>cgklogapp2007</value></property>
    </bean><bean id="sessionFactoryCgk" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
      <property name="mappingDirectoryLocations">   
            ...
        </property>   
     <property name="hibernateProperties">
      <props>
       <prop key="show_sql">true</prop>
       <prop key="hibernate.dialect">org.hibernate.dialect.Oracle9Dialect</prop>
      </props>
     </property>
     <property name="dataSource">
      <ref local="dataSourceCgk"/>
     </property>
     <property name="jtaTransactionManager">   
            <ref bean="jotm" />   
        </property> 
     <property name="lobHandler"><ref local="oracleLobHandler"/></property>
    </bean><bean id="oracleLobHandler" class="org.springframework.jdbc.support.lob.OracleLobHandler">
            <property name="nativeJdbcExtractor"><ref local="nativeJdbcExtractor"/></property>
        </bean>
       <bean id="nativeJdbcExtractor" class="org.springframework.jdbc.support.nativejdbc.SimpleNativeJdbcExtractor">
        </bean>
        
    <bean id="innerDataSourceKjxx" class="org.enhydra.jdbc.standard.StandardXADataSource">
     <property name="transactionManager"><ref local="jotm"/></property>
     <property name="driverName"><value>oracle.jdbc.driver.OracleDriver</value></property>
     <property name="url"><value>jdbc:oracle:thin:@10.67.40.206:1521:zqy</value></property></bean><bean id="dataSourceKjxx" class="org.enhydra.jdbc.pool.StandardXAPoolDataSource">
     <property name="dataSource"><ref local="innerDataSourceKjxx"/></property>
     <property name="transactionManager"><ref local="jotm"/></property>
     <property name="maxSize"><value>10</value></property>
     <property name="user"><value>logdb</value></property>
     <property name="password"><value>logdb</value></property>
    </bean><bean id="sessionFactoryKjxx" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
     <property name="mappingResources">
     ...
     </property>
     <property name="hibernateProperties">
      <props>
       <prop key="show_sql">true</prop>
       <prop key="hibernate.dialect">org.hibernate.dialect.Oracle9Dialect</prop>
      </props>
     </property>
     <property name="dataSource">
      <ref local="dataSourceKjxx"/>
     </property>
     <property name="jtaTransactionManager">   
            <ref bean="jotm" />   
        </property> 
     <property name="lobHandler"><ref local="oracleLobHandler"/></property>
    </bean>
    <bean id="dataSourceBzjh" class="org.enhydra.jdbc.pool.StandardXAPoolDataSource">
     <property name="dataSource"><ref local="innerDataSourceDjk"/></property>
     <property name="transactionManager"><ref local="jotm"/></property>
     <property name="maxSize"><value>10</value></property>
     <property name="user"><value>bzjhcx</value></property>
     <property name="password"><value>bzjhcx123</value></property>
    </bean>
    <bean id="transactionInterceptor" class="org.springframework.transaction.interceptor.TransactionInterceptor">  
      <property name="transactionManager">  
      <ref bean="transactionManager"/>  
      </property>  
      <property name="transactionAttributes">
    <props>
    <prop key="get*">PROPAGATION_REQUIRED</prop>
    <prop key="find*">PROPAGATION_REQUIRED</prop>
    <prop key="*">PROPAGATION_REQUIRED</prop>
    </props>
    </property>
    </bean>  
    <bean id="sessionFactoryBzjh" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
     <property name="mappingResources">
      <list>
    ...
      </list>
     </property>
     <property name="hibernateProperties">
      <props>
       <prop key="show_sql">true</prop>
       <prop key="hibernate.dialect">org.hibernate.dialect.Oracle9Dialect</prop>
      </props>
     </property>
     <property name="dataSource">
      <ref local="dataSourceBzjh"/>
     </property>    
     <property name="lobHandler"><ref local="oracleLobHandler"/></property>
      </bean>
     <bean id="MPjupdateDAO" class="com.zqy.domain.cgk.MPjupdateDAO">
      <property name="sessionFactory">
      <ref bean="sessionFactory" />
      </property>
     </bean></beans>
    其中一共有4个数据源,首先运行没有问题,第一次刷新页面,每一个都可以读取数据库.
    但是读取另一个数据库之后,再回头来读第一个数据库就出错了:
    严重: Servlet.service() for servlet action threw exception
    java.sql.SQLException: ORA-00942: table or view does not exist请问我的错误在哪里呢?帮帮忙阿,我有很多分,可以把所有的分都贡献出来...!期待..
      

  2.   

    这个文件太大,看起来有点乱,我把全部代码的放在了我的博克上了:
    http://freeliver.blog.sohu.com/61814157.html
      

  3.   

    配得太复杂了吧<!-- bean id="transactionManager" class="org.springframework.transaction.jta.JtaTransactionManager" >
       <property name="userTransactionName">
        <value>weblogic/transaction/UserTransaction</value>
       </property>
    </bean-->

    <!-- 事务拦截配置 -->
     
           <bean id="transactionInterceptor" class="org.springframework.transaction.interceptor.TransactionInterceptor">    
                <property name="transactionManager" ref="transactionManager"/>    
                <property name="transactionAttributes">  
                    <props>  
                        <prop key="*">PROPAGATION_REQUIRED</prop>  
                        <prop key="find*">PROPAGATION_REQUIRED,readOnly</prop>  
                    </props>  
                </property>  
            </bean>    
              
            <bean class="org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator">    
                    <property name="beanNames">  
                        <value>*Bo</value>  
                    </property>  
                    <property name="interceptorNames">    
                            <list>    
                                    <value>transactionInterceptor</value>    
                              
                            </list>    
                    </property>    
            </bean>
      

  4.   

    fidelhl(≈小溪≈) ( )大侠 您配置成功了么?好好帮我看看阿.
    拦截配置我也配了阿,关键是现在的问题我找不到原因阿
      

  5.   

    如果你已经在你的application context中定义并获取了JTA PlatformTransactionManager 对象(或许来自通过 JndiObjectFactoryBean 得到的JNDI)并已经将它注入到类似Spring的 JtaTransactionManager 中, 那么最简单的方式就是指定这个bean的引用作为 LocalSessionFactoryBean 的 jtaTransactionManager 属性。Spring将使这个对象被Hibernate所感知。 多数情况下,你还没有得到JTA的 PlatformTransactionManager 实例(由于Spring的 JtaTransactionManager 能够自己找到它),所以你需要自行配置Hibernate并直接寻找资源。 正如Hibernate文档中提到的,这可以通过在Hibernate配置一个应用服务器特定的 TransactionManagerLookup 类来完成。 
      

  6.   

    我现在的问题是:当读取一个数据源之后,立即在读取另外一个数据源,这时候都不出错,然后第三次再来读取第一个数据源的数据,就出错.然后不管它,过上几十分钟,在点击第一个数据源的数据读取,又可以了!我考虑是不是因为在sessionFactory 之间切换管理的时候没有及时切换过来.用MyEclipse 没有办法跟踪sessionFactory的Name.请问 mxm_1123(无名) 我应该具体怎么做呢?谢谢详细指教以下.
      

  7.   

    比较简单的原因你数据源反复的切换但是hibernate方言没有切换