spring2.5,ibatis2.3 oracle11g只读事物不能生效

2019-03-25 13:51|来源: 网路

开发环境:spring2.5,ibatis2.3 oracle11g
执行一个get的service的方法时,日志里中显示设置了connection为readonly,但还是能写入数据库。
怎么才能让readonly的方法不能写入数据库呢,或者说怎么实现这个只读事物呢。
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
		xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
		xmlns:aop="http://www.springframework.org/schema/aop"
		xmlns:tx="http://www.springframework.org/schema/tx"
		xsi:schemaLocation="
			http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
			http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
			http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd" >

   <!--该配置文件主要用于管理项目中的事务 -->
    <bean id="transactionManager"   class="org.springframework.jdbc.datasource.DataSourceTransactionManager">   
        <property name="dataSource">   
            <ref bean="dataSource"/>   
        </property>   
    </bean>
    
	<aop:config>
		<aop:pointcut id="taxService"
			expression="execution(* bj.n22..service.*.*(..))" />
		<aop:advisor advice-ref="txAdvice" pointcut-ref="taxService" />
	</aop:config>

	<tx:advice id="txAdvice" transaction-manager="transactionManager">
		<tx:attributes>
			<tx:method name="save*" />
			<tx:method name="delete*" />
			<tx:method name="update*" />
			<tx:method name="new*" propagation="REQUIRES_NEW" />
			<tx:method name="*" read-only="true" />
		</tx:attributes>
	</tx:advice>
 
    <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">   
    <property name="driverClass" value="oracle.jdbc.driver.OracleDriver"/>   
    <property name="jdbcUrl" value="jdbc:oracle:thin:@192.168.1.251:1521:orcl"/>   
    <property name="user" value="demo"></property>   
    <property name="password" value="demo" />   
    <property name="minPoolSize" value="1" />   
    <property name="maxPoolSize" value="1" />   
    <property name="maxIdleTime" value="1800" />   
    <property name="acquireIncrement" value="2" />   
    <property name="maxStatements" value="0" />   
    <property name="initialPoolSize" value="1" />   
    <property name="idleConnectionTestPeriod" value="1800" />   
    <property name="acquireRetryAttempts" value="30" />   
    <property name="breakAfterAcquireFailure" value="true" />   
    <property name="testConnectionOnCheckout" value="false" />
    <property name="preferredTestQuery" value="select * from dual" /> 
    </bean>           
    

		<!--根据dataSource和configLocation创建一个SqlMapClient-->
	<bean id="sqlMapClient" class="org.springframework.orm.ibatis.SqlMapClientFactoryBean">
		<property name="configLocation">
			<value>/WEB-INF/classes/spring/sqlMapConfig.xml</value>
		</property>
		<property name="dataSource">
			<ref bean="dataSource"/>
		</property>
	</bean>

	<!--将上面的模版类织入到我们的DAO对象中-->
	<bean id="baseDao" class="bj.n22.base.dao.BaseDaoImpl" >
		<property name="sqlMapClient">
			<ref bean="sqlMapClient" />
		</property>
	</bean>
	
	 <import resource="application-log.xml"/>
</beans>



日志输出:
DEBUG [com.opensymphony.xwork2.util.InstantiatingNullHandler:72] Entering nullPropertyValue [target=[com.opensymphony.xwork2.DefaultTextProvider@14b0c98], property=struts]
DEBUG [com.opensymphony.xwork2.DefaultActionProxy:65] Creating an DefaultActionProxy for namespace /log/log and action name edit
DEBUG [org.springframework.beans.factory.support.DefaultListableBeanFactory:389] No bean named 'bj.n22.rms.log.action.LogAction' found in org.springframework.beans.factory.support.DefaultListableBeanFactory@103bc02: defining beans [dataSource,transactionManager,org.springframework.aop.config.internalAutoProxyCreator,taxService,org.springframework.aop.support.DefaultBeanFactoryPointcutAdvisor#0,txAdvice,sqlMapClient,baseDao,logDao,logService]; root of factory hierarchy
DEBUG [org.springframework.beans.factory.support.DefaultListableBeanFactory:1071] Not autowiring property 'actionErrors' of bean 'bj.n22.rms.log.action.LogAction' by name: no matching bean found
DEBUG [org.springframework.beans.factory.support.DefaultListableBeanFactory:1071] Not autowiring property 'actionMessages' of bean 'bj.n22.rms.log.action.LogAction' by name: no matching bean found
DEBUG [org.springframework.beans.factory.support.DefaultListableBeanFactory:1071] Not autowiring property 'fieldErrors' of bean 'bj.n22.rms.log.action.LogAction' by name: no matching bean found
DEBUG [org.springframework.beans.factory.support.DefaultListableBeanFactory:203] Returning cached instance of singleton bean 'logService'
DEBUG [org.springframework.beans.factory.support.DefaultListableBeanFactory:1065] Added autowiring by name from bean name 'bj.n22.rms.log.action.LogAction' via property 'logService' to bean named 'logService'
DEBUG [org.springframework.beans.factory.support.DefaultListableBeanFactory:1071] Not autowiring property 'servletRequest' of bean 'bj.n22.rms.log.action.LogAction' by name: no matching bean found
DEBUG [com.opensymphony.xwork2.interceptor.PrefixMethodInvocationUtil:141] cannot find method [prepareEdit] in action [bj.n22.rms.log.action.LogAction@296cf1]
DEBUG [com.opensymphony.xwork2.interceptor.PrefixMethodInvocationUtil:141] cannot find method [prepareDoEdit] in action [bj.n22.rms.log.action.LogAction@296cf1]
DEBUG [com.opensymphony.xwork2.interceptor.I18nInterceptor:97] intercept '/log/log/edit' {
DEBUG [com.opensymphony.xwork2.interceptor.I18nInterceptor:110] requested_locale=null
DEBUG [com.opensymphony.xwork2.interceptor.I18nInterceptor:140] before Locale=zh_CN
DEBUG [com.opensymphony.xwork2.util.InstantiatingNullHandler:72] Entering nullPropertyValue [target=[bj.n22.rms.log.vo.Log@1cb150a, bj.n22.rms.log.action.LogAction@296cf1, com.opensymphony.xwork2.DefaultTextProvider@14b0c98], property=struts]
DEBUG [org.apache.struts2.interceptor.FileUploadInterceptor:204] Bypassing /log/log/ edit
DEBUG [com.opensymphony.xwork2.interceptor.StaticParametersInterceptor:83] Setting static parameters {}
DEBUG [com.opensymphony.xwork2.interceptor.ParametersInterceptor:148] Setting params logId => [ 1 ]
DEBUG [com.opensymphony.xwork2.util.XWorkConverter:388] Property: logId
DEBUG [com.opensymphony.xwork2.util.XWorkConverter:389] Class: bj.n22.rms.log.vo.Log
DEBUG [com.opensymphony.xwork2.util.XWorkConverter:404] converter is null for property logId. Mapping size: 0
DEBUG [com.opensymphony.xwork2.util.XWorkConverter:278] field-level type converter for property [logId] = none found
DEBUG [com.opensymphony.xwork2.util.XWorkConverter:302] global-level type converter for property [logId] = none found
DEBUG [com.opensymphony.xwork2.util.XWorkConverter:320] falling back to default type converter [com.opensymphony.xwork2.util.XWorkBasicConverter@1470933]
DEBUG [org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor:134] Validating /log/log/edit with method edit.
DEBUG [com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor:183] Invoking validate() on action bj.n22.rms.log.action.LogAction@296cf1
DEBUG [com.opensymphony.xwork2.interceptor.PrefixMethodInvocationUtil:141] cannot find method [validateEdit] in action [bj.n22.rms.log.action.LogAction@296cf1]
DEBUG [com.opensymphony.xwork2.interceptor.PrefixMethodInvocationUtil:141] cannot find method [validateDoEdit] in action [bj.n22.rms.log.action.LogAction@296cf1]
DEBUG [com.opensymphony.xwork2.DefaultActionInvocation:383] Executing action method = edit
DEBUG [org.springframework.jdbc.datasource.DataSourceTransactionManager:319] Using transaction object [org.springframework.jdbc.datasource.DataSourceTransactionManager$DataSourceTransactionObject@1714bf9]
DEBUG [org.springframework.jdbc.datasource.DataSourceTransactionManager:347] Creating new transaction with name [bj.n22.rms.log.service.LogService.get]: PROPAGATION_REQUIRED,ISOLATION_DEFAULT,readOnly
DEBUG [com.mchange.v2.resourcepool.BasicResourcePool:1644] trace com.mchange.v2.resourcepool.BasicResourcePool@1368553 [managed: 1, unused: 0, excluded: 0] (e.g. com.mchange.v2.c3p0.impl.NewPooledConnection@1ba1868)
DEBUG [org.springframework.jdbc.datasource.DataSourceTransactionManager:202] Acquired Connection [com.mchange.v2.c3p0.impl.NewProxyConnection@bbce54] for JDBC transaction
DEBUG [org.springframework.jdbc.datasource.DataSourceUtils:155] Setting JDBC Connection [com.mchange.v2.c3p0.impl.NewProxyConnection@bbce54] read-only
DEBUG [org.springframework.jdbc.datasource.DataSourceTransactionManager:219] Switching JDBC Connection [com.mchange.v2.c3p0.impl.NewProxyConnection@bbce54] to manual commit
DEBUG [org.springframework.transaction.support.TransactionSynchronizationManager:168] Bound value [org.springframework.jdbc.datasource.ConnectionHolder@1e701b0] for key [com.mchange.v2.c3p0.ComboPooledDataSource [ acquireIncrement -> 2, acquireRetryAttempts -> 30, acquireRetryDelay -> 1000, autoCommitOnClose -> false, automaticTestTable -> null, breakAfterAcquireFailure -> true, checkoutTimeout -> 0, connectionCustomizerClassName -> null, connectionTesterClassName -> com.mchange.v2.c3p0.impl.DefaultConnectionTester, dataSourceName -> 1hge15c8e1rol9i71bnat25|9a1621, debugUnreturnedConnectionStackTraces -> false, description -> null, driverClass -> oracle.jdbc.driver.OracleDriver, factoryClassLocation -> null, forceIgnoreUnresolvedTransactions -> false, identityToken -> 1hge15c8e1rol9i71bnat25|9a1621, idleConnectionTestPeriod -> 1800, initialPoolSize -> 1, jdbcUrl -> jdbc:oracle:thin:@192.168.1.251:1521:orcl, maxAdministrativeTaskTime -> 0, maxConnectionAge -> 0, maxIdleTime -> 1800, maxIdleTimeExcessConnections -> 0, maxPoolSize -> 1, maxStatements -> 0, maxStatementsPerConnection -> 0, minPoolSize -> 1, numHelperThreads -> 3, numThreadsAwaitingCheckoutDefaultUser -> 0, preferredTestQuery -> select * from dual, properties -> {user=******, password=******}, propertyCycle -> 0, testConnectionOnCheckin -> false, testConnectionOnCheckout -> false, unreturnedConnectionTimeout -> 0, usesTraditionalReflectiveProxies -> false ]] to thread [http-8777-1]
DEBUG [org.springframework.transaction.support.TransactionSynchronizationManager:222] Initializing transaction synchronization
DEBUG [org.springframework.transaction.interceptor.TransactionInterceptor:288] Getting transaction for [bj.n22.rms.log.service.LogService.get]
DEBUG [org.springframework.orm.ibatis.SqlMapClientTemplate:177] Opened SqlMapSession [com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl@d6999b] for iBATIS operation
DEBUG [org.springframework.transaction.support.TransactionSynchronizationManager:140] Retrieved value [org.springframework.jdbc.datasource.ConnectionHolder@1e701b0] for key [com.mchange.v2.c3p0.ComboPooledDataSource [ acquireIncrement -> 2, acquireRetryAttempts -> 30, acquireRetryDelay -> 1000, autoCommitOnClose -> false, automaticTestTable -> null, breakAfterAcquireFailure -> true, checkoutTimeout -> 0, connectionCustomizerClassName -> null, connectionTesterClassName -> com.mchange.v2.c3p0.impl.DefaultConnectionTester, dataSourceName -> 1hge15c8e1rol9i71bnat25|9a1621, debugUnreturnedConnectionStackTraces -> false, description -> null, driverClass -> oracle.jdbc.driver.OracleDriver, factoryClassLocation -> null, forceIgnoreUnresolvedTransactions -> false, identityToken -> 1hge15c8e1rol9i71bnat25|9a1621, idleConnectionTestPeriod -> 1800, initialPoolSize -> 1, jdbcUrl -> jdbc:oracle:thin:@192.168.1.251:1521:orcl, maxAdministrativeTaskTime -> 0, maxConnectionAge -> 0, maxIdleTime -> 1800, maxIdleTimeExcessConnections -> 0, maxPoolSize -> 1, maxStatements -> 0, maxStatementsPerConnection -> 0, minPoolSize -> 1, numHelperThreads -> 3, numThreadsAwaitingCheckoutDefaultUser -> 0, preferredTestQuery -> select * from dual, properties -> {user=******, password=******}, propertyCycle -> 0, testConnectionOnCheckin -> false, testConnectionOnCheckout -> false, unreturnedConnectionTimeout -> 0, usesTraditionalReflectiveProxies -> false ]] bound to thread [http-8777-1]
DEBUG [java.sql.Connection:27] {conn-100012} Connection
DEBUG [org.springframework.orm.ibatis.SqlMapClientTemplate:194] Obtained JDBC Connection [Transaction-aware proxy for target Connection [com.mchange.v2.c3p0.impl.NewProxyConnection@bbce54]] for iBATIS operation
DEBUG [java.sql.Connection:27] {conn-100012} Preparing Statement:              select SEQ_PRIMARY.NEXTVAL from dual
DEBUG [org.springframework.transaction.support.TransactionSynchronizationManager:140] Retrieved value [org.springframework.jdbc.datasource.ConnectionHolder@1e701b0] for key [com.mchange.v2.c3p0.ComboPooledDataSource [ acquireIncrement -> 2, acquireRetryAttempts -> 30, acquireRetryDelay -> 1000, autoCommitOnClose -> false, automaticTestTable -> null, breakAfterAcquireFailure -> true, checkoutTimeout -> 0, connectionCustomizerClassName -> null, connectionTesterClassName -> com.mchange.v2.c3p0.impl.DefaultConnectionTester, dataSourceName -> 1hge15c8e1rol9i71bnat25|9a1621, debugUnreturnedConnectionStackTraces -> false, description -> null, driverClass -> oracle.jdbc.driver.OracleDriver, factoryClassLocation -> null, forceIgnoreUnresolvedTransactions -> false, identityToken -> 1hge15c8e1rol9i71bnat25|9a1621, idleConnectionTestPeriod -> 1800, initialPoolSize -> 1, jdbcUrl -> jdbc:oracle:thin:@192.168.1.251:1521:orcl, maxAdministrativeTaskTime -> 0, maxConnectionAge -> 0, maxIdleTime -> 1800, maxIdleTimeExcessConnections -> 0, maxPoolSize -> 1, maxStatements -> 0, maxStatementsPerConnection -> 0, minPoolSize -> 1, numHelperThreads -> 3, numThreadsAwaitingCheckoutDefaultUser -> 0, preferredTestQuery -> select * from dual, properties -> {user=******, password=******}, propertyCycle -> 0, testConnectionOnCheckin -> false, testConnectionOnCheckout -> false, unreturnedConnectionTimeout -> 0, usesTraditionalReflectiveProxies -> false ]] bound to thread [http-8777-1]
DEBUG [java.sql.PreparedStatement:27] {pstm-100013} Executing Statement:              select SEQ_PRIMARY.NEXTVAL from dual
DEBUG [java.sql.PreparedStatement:27] {pstm-100013} Parameters: []
DEBUG [java.sql.PreparedStatement:27] {pstm-100013} Types: []
DEBUG [java.sql.ResultSet:27] {rset-100014} ResultSet
DEBUG [java.sql.ResultSet:27] {rset-100014} Header: [NEXTVAL]
DEBUG [java.sql.ResultSet:27] {rset-100014} Result: [21]
DEBUG [org.springframework.transaction.support.TransactionSynchronizationManager:140] Retrieved value [org.springframework.jdbc.datasource.ConnectionHolder@1e701b0] for key [com.mchange.v2.c3p0.ComboPooledDataSource [ acquireIncrement -> 2, acquireRetryAttempts -> 30, acquireRetryDelay -> 1000, autoCommitOnClose -> false, automaticTestTable -> null, breakAfterAcquireFailure -> true, checkoutTimeout -> 0, connectionCustomizerClassName -> null, connectionTesterClassName -> com.mchange.v2.c3p0.impl.DefaultConnectionTester, dataSourceName -> 1hge15c8e1rol9i71bnat25|9a1621, debugUnreturnedConnectionStackTraces -> false, description -> null, driverClass -> oracle.jdbc.driver.OracleDriver, factoryClassLocation -> null, forceIgnoreUnresolvedTransactions -> false, identityToken -> 1hge15c8e1rol9i71bnat25|9a1621, idleConnectionTestPeriod -> 1800, initialPoolSize -> 1, jdbcUrl -> jdbc:oracle:thin:@192.168.1.251:1521:orcl, maxAdministrativeTaskTime -> 0, maxConnectionAge -> 0, maxIdleTime -> 1800, maxIdleTimeExcessConnections -> 0, maxPoolSize -> 1, maxStatements -> 0, maxStatementsPerConnection -> 0, minPoolSize -> 1, numHelperThreads -> 3, numThreadsAwaitingCheckoutDefaultUser -> 0, preferredTestQuery -> select * from dual, properties -> {user=******, password=******}, propertyCycle -> 0, testConnectionOnCheckin -> false, testConnectionOnCheckout -> false, unreturnedConnectionTimeout -> 0, usesTraditionalReflectiveProxies -> false ]] bound to thread [http-8777-1]
DEBUG [org.springframework.orm.ibatis.SqlMapClientTemplate:177] Opened SqlMapSession [com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl@178d7b4] for iBATIS operation
DEBUG [org.springframework.transaction.support.TransactionSynchronizationManager:140] Retrieved value [org.springframework.jdbc.datasource.ConnectionHolder@1e701b0] for key [com.mchange.v2.c3p0.ComboPooledDataSource [ acquireIncrement -> 2, acquireRetryAttempts -> 30, acquireRetryDelay -> 1000, autoCommitOnClose -> false, automaticTestTable -> null, breakAfterAcquireFailure -> true, checkoutTimeout -> 0, connectionCustomizerClassName -> null, connectionTesterClassName -> com.mchange.v2.c3p0.impl.DefaultConnectionTester, dataSourceName -> 1hge15c8e1rol9i71bnat25|9a1621, debugUnreturnedConnectionStackTraces -> false, description -> null, driverClass -> oracle.jdbc.driver.OracleDriver, factoryClassLocation -> null, forceIgnoreUnresolvedTransactions -> false, identityToken -> 1hge15c8e1rol9i71bnat25|9a1621, idleConnectionTestPeriod -> 1800, initialPoolSize -> 1, jdbcUrl -> jdbc:oracle:thin:@192.168.1.251:1521:orcl, maxAdministrativeTaskTime -> 0, maxConnectionAge -> 0, maxIdleTime -> 1800, maxIdleTimeExcessConnections -> 0, maxPoolSize -> 1, maxStatements -> 0, maxStatementsPerConnection -> 0, minPoolSize -> 1, numHelperThreads -> 3, numThreadsAwaitingCheckoutDefaultUser -> 0, preferredTestQuery -> select * from dual, properties -> {user=******, password=******}, propertyCycle -> 0, testConnectionOnCheckin -> false, testConnectionOnCheckout -> false, unreturnedConnectionTimeout -> 0, usesTraditionalReflectiveProxies -> false ]] bound to thread [http-8777-1]
DEBUG [java.sql.Connection:27] {conn-100015} Connection
DEBUG [org.springframework.orm.ibatis.SqlMapClientTemplate:194] Obtained JDBC Connection [Transaction-aware proxy for target Connection [com.mchange.v2.c3p0.impl.NewProxyConnection@bbce54]] for iBATIS operation
DEBUG [java.sql.Connection:27] {conn-100015} Preparing Statement:              insert into TEST_LOG                         (logid,username,logTime)             values      (?,?,?)
DEBUG [org.springframework.transaction.support.TransactionSynchronizationManager:140] Retrieved value [org.springframework.jdbc.datasource.ConnectionHolder@1e701b0] for key [com.mchange.v2.c3p0.ComboPooledDataSource [ acquireIncrement -> 2, acquireRetryAttempts -> 30, acquireRetryDelay -> 1000, autoCommitOnClose -> false, automaticTestTable -> null, breakAfterAcquireFailure -> true, checkoutTimeout -> 0, connectionCustomizerClassName -> null, connectionTesterClassName -> com.mchange.v2.c3p0.impl.DefaultConnectionTester, dataSourceName -> 1hge15c8e1rol9i71bnat25|9a1621, debugUnreturnedConnectionStackTraces -> false, description -> null, driverClass -> oracle.jdbc.driver.OracleDriver, factoryClassLocation -> null, forceIgnoreUnresolvedTransactions -> false, identityToken -> 1hge15c8e1rol9i71bnat25|9a1621, idleConnectionTestPeriod -> 1800, initialPoolSize -> 1, jdbcUrl -> jdbc:oracle:thin:@192.168.1.251:1521:orcl, maxAdministrativeTaskTime -> 0, maxConnectionAge -> 0, maxIdleTime -> 1800, maxIdleTimeExcessConnections -> 0, maxPoolSize -> 1, maxStatements -> 0, maxStatementsPerConnection -> 0, minPoolSize -> 1, numHelperThreads -> 3, numThreadsAwaitingCheckoutDefaultUser -> 0, preferredTestQuery -> select * from dual, properties -> {user=******, password=******}, propertyCycle -> 0, testConnectionOnCheckin -> false, testConnectionOnCheckout -> false, unreturnedConnectionTimeout -> 0, usesTraditionalReflectiveProxies -> false ]] bound to thread [http-8777-1]
DEBUG [java.sql.PreparedStatement:27] {pstm-100016} Executing Statement:              insert into TEST_LOG                         (logid,username,logTime)             values      (?,?,?)
DEBUG [java.sql.PreparedStatement:27] {pstm-100016} Parameters: [21, get, null]
DEBUG [java.sql.PreparedStatement:27] {pstm-100016} Types: [java.lang.Long, java.lang.String, null]
DEBUG [org.springframework.transaction.support.TransactionSynchronizationManager:140] Retrieved value [org.springframework.jdbc.datasource.ConnectionHolder@1e701b0] for key [com.mchange.v2.c3p0.ComboPooledDataSource [ acquireIncrement -> 2, acquireRetryAttempts -> 30, acquireRetryDelay -> 1000, autoCommitOnClose -> false, automaticTestTable -> null, breakAfterAcquireFailure -> true, checkoutTimeout -> 0, connectionCustomizerClassName -> null, connectionTesterClassName -> com.mchange.v2.c3p0.impl.DefaultConnectionTester, dataSourceName -> 1hge15c8e1rol9i71bnat25|9a1621, debugUnreturnedConnectionStackTraces -> false, description -> null, driverClass -> oracle.jdbc.driver.OracleDriver, factoryClassLocation -> null, forceIgnoreUnresolvedTransactions -> false, identityToken -> 1hge15c8e1rol9i71bnat25|9a1621, idleConnectionTestPeriod -> 1800, initialPoolSize -> 1, jdbcUrl -> jdbc:oracle:thin:@192.168.1.251:1521:orcl, maxAdministrativeTaskTime -> 0, maxConnectionAge -> 0, maxIdleTime -> 1800, maxIdleTimeExcessConnections -> 0, maxPoolSize -> 1, maxStatements -> 0, maxStatementsPerConnection -> 0, minPoolSize -> 1, numHelperThreads -> 3, numThreadsAwaitingCheckoutDefaultUser -> 0, preferredTestQuery -> select * from dual, properties -> {user=******, password=******}, propertyCycle -> 0, testConnectionOnCheckin -> false, testConnectionOnCheckout -> false, unreturnedConnectionTimeout -> 0, usesTraditionalReflectiveProxies -> false ]] bound to thread [http-8777-1]
DEBUG [org.springframework.orm.ibatis.SqlMapClientTemplate:177] Opened SqlMapSession [com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl@17b4650] for iBATIS operation
DEBUG [org.springframework.transaction.support.TransactionSynchronizationManager:140] Retrieved value [org.springframework.jdbc.datasource.ConnectionHolder@1e701b0] for key [com.mchange.v2.c3p0.ComboPooledDataSource [ acquireIncrement -> 2, acquireRetryAttempts -> 30, acquireRetryDelay -> 1000, autoCommitOnClose -> false, automaticTestTable -> null, breakAfterAcquireFailure -> true, checkoutTimeout -> 0, connectionCustomizerClassName -> null, connectionTesterClassName -> com.mchange.v2.c3p0.impl.DefaultConnectionTester, dataSourceName -> 1hge15c8e1rol9i71bnat25|9a1621, debugUnreturnedConnectionStackTraces -> false, description -> null, driverClass -> oracle.jdbc.driver.OracleDriver, factoryClassLocation -> null, forceIgnoreUnresolvedTransactions -> false, identityToken -> 1hge15c8e1rol9i71bnat25|9a1621, idleConnectionTestPeriod -> 1800, initialPoolSize -> 1, jdbcUrl -> jdbc:oracle:thin:@192.168.1.251:1521:orcl, maxAdministrativeTaskTime -> 0, maxConnectionAge -> 0, maxIdleTime -> 1800, maxIdleTimeExcessConnections -> 0, maxPoolSize -> 1, maxStatements -> 0, maxStatementsPerConnection -> 0, minPoolSize -> 1, numHelperThreads -> 3, numThreadsAwaitingCheckoutDefaultUser -> 0, preferredTestQuery -> select * from dual, properties -> {user=******, password=******}, propertyCycle -> 0, testConnectionOnCheckin -> false, testConnectionOnCheckout -> false, unreturnedConnectionTimeout -> 0, usesTraditionalReflectiveProxies -> false ]] bound to thread [http-8777-1]
DEBUG [java.sql.Connection:27] {conn-100017} Connection
DEBUG [org.springframework.orm.ibatis.SqlMapClientTemplate:194] Obtained JDBC Connection [Transaction-aware proxy for target Connection [com.mchange.v2.c3p0.impl.NewProxyConnection@bbce54]] for iBATIS operation
DEBUG [java.sql.Connection:27] {conn-100017} Preparing Statement:              select *              from TEST_LOG where logid=?
DEBUG [org.springframework.transaction.support.TransactionSynchronizationManager:140] Retrieved value [org.springframework.jdbc.datasource.ConnectionHolder@1e701b0] for key [com.mchange.v2.c3p0.ComboPooledDataSource [ acquireIncrement -> 2, acquireRetryAttempts -> 30, acquireRetryDelay -> 1000, autoCommitOnClose -> false, automaticTestTable -> null, breakAfterAcquireFailure -> true, checkoutTimeout -> 0, connectionCustomizerClassName -> null, connectionTesterClassName -> com.mchange.v2.c3p0.impl.DefaultConnectionTester, dataSourceName -> 1hge15c8e1rol9i71bnat25|9a1621, debugUnreturnedConnectionStackTraces -> false, description -> null, driverClass -> oracle.jdbc.driver.OracleDriver, factoryClassLocation -> null, forceIgnoreUnresolvedTransactions -> false, identityToken -> 1hge15c8e1rol9i71bnat25|9a1621, idleConnectionTestPeriod -> 1800, initialPoolSize -> 1, jdbcUrl -> jdbc:oracle:thin:@192.168.1.251:1521:orcl, maxAdministrativeTaskTime -> 0, maxConnectionAge -> 0, maxIdleTime -> 1800, maxIdleTimeExcessConnections -> 0, maxPoolSize -> 1, maxStatements -> 0, maxStatementsPerConnection -> 0, minPoolSize -> 1, numHelperThreads -> 3, numThreadsAwaitingCheckoutDefaultUser -> 0, preferredTestQuery -> select * from dual, properties -> {user=******, password=******}, propertyCycle -> 0, testConnectionOnCheckin -> false, testConnectionOnCheckout -> false, unreturnedConnectionTimeout -> 0, usesTraditionalReflectiveProxies -> false ]] bound to thread [http-8777-1]
DEBUG [java.sql.PreparedStatement:27] {pstm-100018} Executing Statement:              select *              from TEST_LOG where logid=?
DEBUG [java.sql.PreparedStatement:27] {pstm-100018} Parameters: [1]
DEBUG [java.sql.PreparedStatement:27] {pstm-100018} Types: [java.lang.Long]
DEBUG [java.sql.ResultSet:27] {rset-100019} ResultSet
DEBUG [java.sql.ResultSet:27] {rset-100019} Header: [LOGID, USERNAME, LOGTIME]
DEBUG [java.sql.ResultSet:27] {rset-100019} Result: [1, 测试new事物, null]
DEBUG [org.springframework.transaction.support.TransactionSynchronizationManager:140] Retrieved value [org.springframework.jdbc.datasource.ConnectionHolder@1e701b0] for key [com.mchange.v2.c3p0.ComboPooledDataSource [ acquireIncrement -> 2, acquireRetryAttempts -> 30, acquireRetryDelay -> 1000, autoCommitOnClose -> false, automaticTestTable -> null, breakAfterAcquireFailure -> true, checkoutTimeout -> 0, connectionCustomizerClassName -> null, connectionTesterClassName -> com.mchange.v2.c3p0.impl.DefaultConnectionTester, dataSourceName -> 1hge15c8e1rol9i71bnat25|9a1621, debugUnreturnedConnectionStackTraces -> false, description -> null, driverClass -> oracle.jdbc.driver.OracleDriver, factoryClassLocation -> null, forceIgnoreUnresolvedTransactions -> false, identityToken -> 1hge15c8e1rol9i71bnat25|9a1621, idleConnectionTestPeriod -> 1800, initialPoolSize -> 1, jdbcUrl -> jdbc:oracle:thin:@192.168.1.251:1521:orcl, maxAdministrativeTaskTime -> 0, maxConnectionAge -> 0, maxIdleTime -> 1800, maxIdleTimeExcessConnections -> 0, maxPoolSize -> 1, maxStatements -> 0, maxStatementsPerConnection -> 0, minPoolSize -> 1, numHelperThreads -> 3, numThreadsAwaitingCheckoutDefaultUser -> 0, preferredTestQuery -> select * from dual, properties -> {user=******, password=******}, propertyCycle -> 0, testConnectionOnCheckin -> false, testConnectionOnCheckout -> false, unreturnedConnectionTimeout -> 0, usesTraditionalReflectiveProxies -> false ]] bound to thread [http-8777-1]
DEBUG [org.springframework.transaction.interceptor.TransactionInterceptor:317] Completing transaction for [bj.n22.rms.log.service.LogService.get]
DEBUG [org.springframework.jdbc.datasource.DataSourceTransactionManager:833] Triggering beforeCommit synchronization
DEBUG [org.springframework.jdbc.datasource.DataSourceTransactionManager:846] Triggering beforeCompletion synchronization
DEBUG [org.springframework.jdbc.datasource.DataSourceTransactionManager:660] Initiating transaction commit
DEBUG [org.springframework.jdbc.datasource.DataSourceTransactionManager:259] Committing JDBC transaction on Connection [com.mchange.v2.c3p0.impl.NewProxyConnection@bbce54]
DEBUG [org.springframework.jdbc.datasource.DataSourceTransactionManager:859] Triggering afterCommit synchronization
DEBUG [org.springframework.jdbc.datasource.DataSourceTransactionManager:875] Triggering afterCompletion synchronization
DEBUG [org.springframework.transaction.support.TransactionSynchronizationManager:276] Clearing transaction synchronization
DEBUG [org.springframework.transaction.support.TransactionSynchronizationManager:193] Removed value [org.springframework.jdbc.datasource.ConnectionHolder@1e701b0] for key [com.mchange.v2.c3p0.ComboPooledDataSource [ acquireIncrement -> 2, acquireRetryAttempts -> 30, acquireRetryDelay -> 1000, autoCommitOnClose -> false, automaticTestTable -> null, breakAfterAcquireFailure -> true, checkoutTimeout -> 0, connectionCustomizerClassName -> null, connectionTesterClassName -> com.mchange.v2.c3p0.impl.DefaultConnectionTester, dataSourceName -> 1hge15c8e1rol9i71bnat25|9a1621, debugUnreturnedConnectionStackTraces -> false, description -> null, driverClass -> oracle.jdbc.driver.OracleDriver, factoryClassLocation -> null, forceIgnoreUnresolvedTransactions -> false, identityToken -> 1hge15c8e1rol9i71bnat25|9a1621, idleConnectionTestPeriod -> 1800, initialPoolSize -> 1, jdbcUrl -> jdbc:oracle:thin:@192.168.1.251:1521:orcl, maxAdministrativeTaskTime -> 0, maxConnectionAge -> 0, maxIdleTime -> 1800, maxIdleTimeExcessConnections -> 0, maxPoolSize -> 1, maxStatements -> 0, maxStatementsPerConnection -> 0, minPoolSize -> 1, numHelperThreads -> 3, numThreadsAwaitingCheckoutDefaultUser -> 0, preferredTestQuery -> select * from dual, properties -> {user=******, password=******}, propertyCycle -> 0, testConnectionOnCheckin -> false, testConnectionOnCheckout -> false, unreturnedConnectionTimeout -> 0, usesTraditionalReflectiveProxies -> false ]] from thread [http-8777-1]
DEBUG [org.springframework.jdbc.datasource.DataSourceUtils:202] Resetting read-only flag of JDBC Connection [com.mchange.v2.c3p0.impl.NewProxyConnection@bbce54]
DEBUG [org.springframework.jdbc.datasource.DataSourceTransactionManager:314] Releasing JDBC Connection [com.mchange.v2.c3p0.impl.NewProxyConnection@bbce54] after transaction
DEBUG [org.springframework.jdbc.datasource.DataSourceUtils:312] Returning JDBC Connection to DataSource
DEBUG [com.mchange.v2.resourcepool.BasicResourcePool:1644] trace com.mchange.v2.resourcepool.BasicResourcePool@1368553 [managed: 1, unused: 0, excluded: 0] (e.g. com.mchange.v2.c3p0.impl.NewPooledConnection@1ba1868)
DEBUG [org.springframework.beans.factory.support.DefaultListableBeanFactory:389] No bean named 'org.apache.struts2.dispatcher.VelocityResult' found in org.springframework.beans.factory.support.DefaultListableBeanFactory@103bc02: defining beans [dataSource,transactionManager,org.springframework.aop.config.internalAutoProxyCreator,taxService,org.springframework.aop.support.DefaultBeanFactoryPointcutAdvisor#0,txAdvice,sqlMapClient,baseDao,logDao,logService]; root of factory hierarchy
DEBUG [org.springframework.beans.factory.support.DefaultListableBeanFactory:183] Ignoring constructor [public org.apache.struts2.dispatcher.VelocityResult(java.lang.String)] of bean 'org.apache.struts2.dispatcher.VelocityResult': org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.apache.struts2.dispatcher.VelocityResult': Unsatisfied dependency expressed through constructor argument with index 0 of type [java.lang.String]: No unique bean of type [java.lang.String] is defined: Unsatisfied dependency of type [class java.lang.String]: expected at least 1 matching bean
DEBUG [org.springframework.beans.factory.support.DefaultListableBeanFactory:1071] Not autowiring property 'velocityManager' of bean 'org.apache.struts2.dispatcher.VelocityResult' by name: no matching bean found
DEBUG [com.opensymphony.xwork2.util.InstantiatingNullHandler:72] Entering nullPropertyValue [target=[bj.n22.rms.log.vo.Log@1cb150a, bj.n22.rms.log.action.LogAction@296cf1, com.opensymphony.xwork2.DefaultTextProvider@14b0c98], property=message]
DEBUG [com.opensymphony.xwork2.util.InstantiatingNullHandler:72] Entering nullPropertyValue [target=[bj.n22.rms.log.vo.Log@1cb150a, bj.n22.rms.log.action.LogAction@296cf1, com.opensymphony.xwork2.DefaultTextProvider@14b0c98], property=message]
DEBUG [com.opensymphony.xwork2.util.InstantiatingNullHandler:72] Entering nullPropertyValue [target=[bj.n22.rms.log.vo.Log@1cb150a, bj.n22.rms.log.action.LogAction@296cf1, com.opensymphony.xwork2.DefaultTextProvider@14b0c98], property=struts_token]
DEBUG [com.opensymphony.xwork2.interceptor.I18nInterceptor:145] after Locale=zh_CN
DEBUG [com.opensymphony.xwork2.interceptor.I18nInterceptor:149] intercept }
DEBUG [com.mchange.v2.resourcepool.BasicResourcePool:1935] Checking for expired resources - Thu Mar 24 10:36:00 CST 2011 [com.mchange.v2.resourcepool.BasicResourcePool@1368553]
DEBUG [com.mchange.v2.resourcepool.BasicResourcePool:1447] BEGIN check for expired resources.  [com.mchange.v2.resourcepool.BasicResourcePool@1368553]
DEBUG [com.mchange.v2.resourcepool.BasicResourcePool:1468] FINISHED check for expired resources.  [com.mchange.v2.resourcepool.BasicResourcePool@1368553]

问题补充:
finallygo 写道
要保证只读,需要设置数据库的用户的权限,这里的只读,只是在保证在事务方面进行优化

首先使用hibernate的事务管理器可以只读的,肯定不能写入了,只是用jdbc管理就没用了。

问题补充:
finallygo 写道
嗯,你说的有一定的道理,我也看了一下下面的这个文章
http://webwork.iteye.com/blog/576529

看了一下,hibernate进行了处理,没弄明白spring使用jdbc只读怎么处理。还请明白的说道说道大家是怎么做的呢。这个虽然关系不大,总感觉不爽

相关问答

更多
  • 有定义一个不带参数的构造方法,你可能在里面定义了带参数的构造方法,而把默认的构造方法给覆盖了! 如果你要使用这个带参数的构造方法,你就是用注解@resource或者@Auto...的注解注入参数就可以了!
  • 在 Spring官网下jar包,里面自带了个jpetstore 项目,是用iBATIS + Spring + Struts技术实现的。
  • 首先保证三个框架的核心包要有,然后就是struts2整合spring的包,至于ibatis的整合应该看spring整合它的方式,把三者环境加载后看看异常有没有提示没找到什么类,再找相应的包即可
  • 重新装, 别无他法。 记得卸载干净再装.只用开启这三个服务就可以使用了. lsnrctl start;net start OracleOraDb11g_home1TNSListener;net start OracleServiceORCL
  • oracle11g安装问题[2023-02-06]

    你的系统是 ghost 的? 试下全新安装。 11G 我没用过,XP(win7) 10G 我格式化后重装不下数十次;每次都没有问题,只要格式化系统盘就OK了,其他盘只要删除与Oracle有关的路径或者安装时不选择次路径即可。
  • 你先用 系统 SQL PLUS 连接一下看看能不能连接上 如果能连接上载确认是不是 PL SQL的错误。 我感觉是 你 oracle_11 装的有问题
  • 在控制面板---管理工具----服务下找到oracle的相关启动服务。 (用toad 或者 plsql 工具)
  • 从诞生之初,Spring框架就坚守它的宗旨:简化企业级应用开发,同时给复杂问题提供强大的、非侵入性解决方案。一年前发布的Spring2.0就把这些主题推到了一个新的高度。XMLnbsp;Schema的支持和自定义命名空间的使用大大减少了基于XML的配置。使用Java5及更新版本java的开发人员如今可以利用植入了像泛型(generic)和注解等新语言特性的Spring库。最近,和AspectJ表达式语言的紧密集成,使得以非侵入方式添加跨越定义良好的Spring管理对象分组的行为成为可能。新发布的Spring ...
  • Oracle11g怎么配置[2022-01-04]

    你好,希望可以给你个参考!谢谢 所谓双机热备,就是将中心服务器安装成互为备份的两台服务器,并且在同一时间内只有一台服务器运行。当其中运行着的一台服务器出现故障无法启动时,另一台备份服务器会迅速的自动启动并运行。我们来看看在WIN2000服务器版下的实现过程。 一、 硬件准备及基本安装综述 网络服务器 两台 网络服务网卡 四块 服务器硬盘 两块 SCSI磁盘阵列 一个 SCSI硬盘 三块 首先是将两台服务器都配置成双网卡,并分别安装Win2000 Advance Server(高级服务器版)。之后配置网络环境 ...
  • 您需要使用[DBA|ALL|USER]_CONSTRAINTS视图加入[DBA|ALL|USER]_CONS_COLUMNS视图。 NOT NULL约束是类型C UNIQUE约束是U型。 SELECT a.table_name, b.column_name, a.constraint_type FROM dba_constraints a JOIN dba_cons_columns b ON a.owner = b.owner AND a.constraint_name = ...