环境Spring+Mybatis
<!-- 配置事务管理器 -->
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource" />
</bean>
<!-- 声明式事物管理 --> <tx:advice id="txAdvice" transaction-manager="transactionManager"> <tx:attributes> <tx:method name="get*" read-only="true" /> <tx:method name="find*" read-only="true" /> <tx:method name="load*" read-only="true" /> <tx:method name="query*" read-only="true" /> <tx:method name="add*" read-only="false" rollback-for="Exception" propagation="REQUIRED"/> <tx:method name="save*" read-only="false" rollback-for="Exception" propagation="REQUIRED"/> <tx:method name="insert*" read-only="false" rollback-for="Exception" propagation="REQUIRED"/> <tx:method name="update*" read-only="false" rollback-for="Exception" propagation="REQUIRED"/> <tx:method name="modify*" read-only="false" rollback-for="Exception" propagation="REQUIRED"/> <tx:method name="delete*" read-only="false" rollback-for="Exception" propagation="REQUIRED"/> <!-- <tx:method name="*" read-only="true"/> --> </tx:attributes> </tx:advice>
以上只为示例,使用事务控制连接数据库方法规范,只读方法和操作方法
有的项目中没有配置声明式事务,是在service层用
@Transactional(readOnly = false)
注解进行控制
相关知识
mysql四种事务隔离级别
基于STM32的农业病虫害检测检测系统:OpenCV、MQTT、Flask框架、MySQL(代码示例)
java对mysql数据库的增添,查询操作
mysql resultset null
用另一种方式解决WARNING: Retrying (Retry(total=4, connect
使用Python调用mysql
Mysql重点知识
MySQL绿色版安装【一键安装脚本】
mysql 手动查询 中文查不到
MySQL if else相关函数
网址: Mysql 错误 Connection is read https://m.huajiangbk.com/newsview1230495.html
上一篇: 大足南山公园蔷薇园的蔷薇花开了, |
下一篇: 【南京晨报/爱南京】月季、玫瑰、 |