How does the java code think that sql executes in which database? The solution to the viewing idea of the local server and the server.

problem description

Local read-write separation uses spring"s aop, which has only one library locally and multiple libraries online.

the environmental background of the problems and what methods you have tried

there is no problem with the local update. When you report an error online, the update error message is as follows:
org.springframework.jdbc.UncategorizedSQLException:-sharp-sharp-sharp Error updating database. Cause: java.sql.SQLException: The MySQL server is running with the-- read-only option so it cannot execute this statement-sharp-sharp-sharp The error may involve com.finance.core.acn.mapper.SequenceIDMapper.updateByPrimaryKeySelective-Inline-sharp-sharp-sharp The error occurred while setting parameters-sharp-sharp-sharp SQL: update t_increment_sequence SET current_value =?, code =? Where id =?-sharp-sharp-sharp Cause: java.sql.SQLException: The MySQL server is running with the-- read-only option so it cannot execute this statement; uncategorized SQLException for SQL []; SQL state [HY000]; error code [1290]; The MySQL server is running with the-- read-only option so it cannot execute this statement; nested exception is java.sql.SQLException: The MySQL server is running with the-- read-only option so it cannot execute this statement

    at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:83) 
    at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:80) 
    at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:71) 
    at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:364) 
    at com.sun.proxy.$Proxy12.update(Unknown Source) 
    at org.mybatis.spring.SqlSessionTemplate.update(SqlSessionTemplate.java:250) 
    at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:49) 
    at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:43) 
    at com.sun.proxy.$Proxy35.updateByPrimaryKeySelective(Unknown Source) 
    at com.finance.core.acn.service.impl.IDGeneratorServiceImpl.querySequenceNumPerMonth(IDGeneratorServiceImpl.java:54) 
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 
    at java.lang.reflect.Method.invoke(Method.java:498) 
    at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:309) 
    at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183) 
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150) 
    at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110) 
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) 
    at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110) 
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) 
    at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:90) 
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) 
    at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202) 
    at com.sun.proxy.$Proxy36.querySequenceNumPerMonth(Unknown Source) 
    at com.finance.midware.acn.service.impl.BizSyncDataServiceImpl.generateBatchNo(BizSyncDataServiceImpl.java:1128) 
    at com.finance.midware.acn.service.impl.BizSyncDataServiceImpl.querySettleDataByBizSyncTypeAndDateRange(BizSyncDataServiceImpl.java:215) 
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 
    at java.lang.reflect.Method.invoke(Method.java:498) 
    at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:309) 
    at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183) 
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150) 
    at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110) 
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) 
    at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110) 
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) 
    at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:90) 
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) 
    at com.arch.db.aop.ReadMethodInterceptor.invoke(ReadMethodInterceptor.java:31) 
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:161) 
    at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202) 
    at com.sun.proxy.$Proxy40.querySettleDataByBizSyncTypeAndDateRange(Unknown Source) 
    at com.finance.midware.schedule.dispatch.ProduceACNSettlementDataDispatch.generateInterfaceData(ProduceACNSettlementDataDispatch.java:109) 
    at com.finance.midware.schedule.dispatch.ProduceACNSettlementDataDispatch.execute(ProduceACNSettlementDataDispatch.java:76) 
    at com.schedule.AbsRunOnceScheduleTaskDeal.execute(AbsRunOnceScheduleTaskDeal.java:42) 
    at com.schedule.taskmanagerScheduleProcessorSleep.executeTaskScheduleProcessorSleep.java:342) 
    at com.schedule.taskmanagerScheduleProcessorSleep.runScheduleProcessorSleep.java:242) 
    at java.lang.Thread.run(Thread.java:748) 
Caused by: java.sql.SQLException: The MySQL server is running with the --read-only option so it cannot execute this statement 
    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1073) 
    at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4096) 
    at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4028) 
    at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2490) 
    at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2651) 
    at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2683) 
    at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2144) 
    at com.mysql.jdbc.PreparedStatement.execute(PreparedStatement.java:1379) 
    at com.alibaba.druid.filter.FilterChainImpl.preparedStatement_execute(FilterChainImpl.java:2931) 
    at com.alibaba.druid.filter.FilterEventAdapter.preparedStatement_execute(FilterEventAdapter.java:440) 
    at com.alibaba.druid.filter.FilterChainImpl.preparedStatement_execute(FilterChainImpl.java:2929) 
    at com.alibaba.druid.proxy.jdbc.PreparedStatementProxyImpl.execute(PreparedStatementProxyImpl.java:131) 
    at com.alibaba.druid.pool.DruidPooledPreparedStatement.execute(DruidPooledPreparedStatement.java:493) 
    at org.apache.ibatis.executor.statement.PreparedStatementHandler.update(PreparedStatementHandler.java:41) 
    at org.apache.ibatis.executor.statement.RoutingStatementHandler.update(RoutingStatementHandler.java:66) 
    at org.apache.ibatis.executor.SimpleExecutor.doUpdate(SimpleExecutor.java:45) 
    at org.apache.ibatis.executor.BaseExecutor.update(BaseExecutor.java:100) 
    at org.apache.ibatis.executor.CachingExecutor.update(CachingExecutor.java:75) 
    at org.apache.ibatis.session.defaults.DefaultSqlSession.update(DefaultSqlSession.java:148) 
    at sun.reflect.GeneratedMethodAccessor457.invoke(Unknown Source) 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 
    at java.lang.reflect.Method.invoke(Method.java:498) 
    at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:354) 

related codes

/ / Please paste the code text below (do not replace the code with pictures)

what result do you expect? What is the error message actually seen?

Apr.27,2021

you have misconfigured dataSource and performed a update operation in the read-only library, so if you report this error, check the configuration file and code to find the problem. I would like to ask what is the implementation of read-write separation using AOP? My previous project was to configure two data sources, MyBatis and Hibernate with different data sources.


think about it, only log

Menu