java.sql.SQLException: Connection is read-only 问题产生的原因及解决办法

org.springframework.dao.TransientDataAccessResourceException: 
### Error updating database.  Cause: java.sql.SQLException: Connection is read-only. Queries leading to data modification are not allowed
### The error may involve com.segi.uhomecp.charging.api.accrualBasis.dao.BillAccrualBasisCycleMapper.insertBatch-Inline
### The error occurred while setting parameters
### Cause: java.sql.SQLException: Connection is read-only. Queries leading to data modification are not allowed
; SQL []; Connection is read-only. Queries leading to data modification are not allowed; nested exception is java.sql.SQLException: Connection is read-only. Queries leading to data modification are not allowed
	at org.springframework.jdbc.support.SQLStateSQLExceptionTranslator.doTranslate(SQLStateSQLExceptionTranslator.java:106)
	at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:72)
	at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:80)
	at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:80)
	at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:73)
	at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:446)
	at com.sun.proxy.$Proxy17.insert(Unknown Source)
	at org.mybatis.spring.SqlSessionTemplate.insert(SqlSessionTemplate.java:278)
	at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:79)
	at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:40)
	at com.sun.proxy.$Proxy23.insertBatch(Unknown Source)
...

只读权限,一般如果报了这个错,是项目中事务配置文件的问题。


		


		
			
			
			
			
			
			
			
			
			
			
			
			
			
			
			
			
		

 

因为事务是配置在service层,因此检查了我service层接口的代码,发现方法名是query开头的,service调用的query方法根本就没有事务。

问题原因找到了,解决办法也很简单,修改接口名称(跟配置文件中匹配即可)

 

你可能感兴趣的:(java.sql.SQLException: Connection is read-only 问题产生的原因及解决办法)