单条事物日志
System.out.println("threadId==="+Thread.currentThread().getId());
return jdbcTemplate.queryForList(sql);
//创建事物 2015-12-13 19:05:06 [ main:7232 ] - [ DEBUG ] org.springframework.transaction.support.AbstractPlatformTransactionManager.getTransaction(AbstractPlatformTransactionManager.java:366) Creating new transaction with name [com.zzm.spider.dao.impl.BasicDaoImpl2.queryForListMap]: PROPAGATION_REQUIRED,ISOLATION_DEFAULT; '',-java.lang.Exception //获取数据库连接池并加入到线程上线文 2015-12-13 19:05:08 [ main:9666 ] - [ DEBUG ] org.springframework.jdbc.datasource.DataSourceTransactionManager.doBegin(DataSourceTransactionManager.java:205) Acquired Connection for JDBC transaction // 2015-12-13 19:05:09 [ main:9714 ] - [ DEBUG ] org.springframework.jdbc.datasource.DataSourceTransactionManager.doBegin(DataSourceTransactionManager.java:222) Switching JDBC Connection to manual commit threadId===1 2015-12-13 19:05:09 [ main:9729 ] - [ DEBUG ] org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:435) Executing SQL query [select * from website] threadId===1 2015-12-13 19:05:16 [ main:17141 ] - [ DEBUG ] org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:753) Initiating transaction commit //提交事物 2015-12-13 19:05:16 [ main:17157 ] - [ DEBUG ] org.springframework.jdbc.datasource.DataSourceTransactionManager.doCommit(DataSourceTransactionManager.java:265) Committing JDBC transaction on Connection //释放数据库连接池,从当前线程上下文中删除 2015-12-13 19:05:16 [ main:17173 ] - [ DEBUG ] org.springframework.jdbc.datasource.DataSourceTransactionManager.doCleanupAfterCompletion(DataSourceTransactionManager.java:323) Releasing JDBC Connection 2015-12-13 19:05:16 [ main:17173 ] - [ DEBUG ] org.springframework.jdbc.datasource.DataSourceUtils.doReleaseConnection(DataSourceUtils.java:328) Returning JDBC Connection to DataSource
for(int i=0;i<8;i++){ //使用当前的 transaction serviceUtil.queryTasks(); } System.out.println("threadId==="+Thread.currentThread().getId()); return jdbcTemplate.queryForList(sql);
2015-12-13 19:10:50 [ main:9219 ] - [ DEBUG ] org.springframework.transaction.support.AbstractPlatformTransactionManager.getTransaction(AbstractPlatformTransactionManager.java:366) Creating new transaction with name [com.zzm.spider.dao.impl.BasicDaoImpl2.queryForListMap]: PROPAGATION_REQUIRED,ISOLATION_DEFAULT; '',-java.lang.Exception 2015-12-13 19:10:53 [ main:11856 ] - [ DEBUG ] org.springframework.jdbc.datasource.DataSourceTransactionManager.doBegin(DataSourceTransactionManager.java:205) Acquired Connection [, MySQL Connector Java] for JDBC transaction 2015-12-13 19:10:53 [ main:11935 ] - [ DEBUG ] org.springframework.jdbc.datasource.DataSourceTransactionManager.doBegin(DataSourceTransactionManager.java:222) Switching JDBC Connection [, MySQL Connector Java] to manual commit 2015-12-13 19:10:53 [ main:11951 ] - [ DEBUG ] org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:246) Returning cached instance of singleton bean 'transactionManager' 2015-12-13 19:10:53 [ main:11951 ] - [ DEBUG ] org.springframework.transaction.support.AbstractPlatformTransactionManager.handleExistingTransaction(AbstractPlatformTransactionManager.java:471) Participating in existing transaction 2015-12-13 19:10:53 [ main:12185 ] - [ DEBUG ] org.crazycake.jdbcTemplateTool.utils.CatalogUtils.changeCatalog(CatalogUtils.java:34) real sql: select * from query_task where status = 0 2015-12-13 19:10:53 [ main:12185 ] - [ DEBUG ] org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:435) Executing SQL query [select * from query_task where status = 0] threadId===1 2015-12-13 19:11:02 [ main:20574 ] - [ DEBUG ] org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:246) Returning cached instance of singleton bean 'transactionManager' 2015-12-13 19:11:02 [ main:20574 ] - [ DEBUG ] org.springframework.transaction.support.AbstractPlatformTransactionManager.handleExistingTransaction(AbstractPlatformTransactionManager.java:471) Participating in existing transaction 2015-12-13 19:11:02 [ main:20574 ] - [ DEBUG ] org.crazycake.jdbcTemplateTool.utils.CatalogUtils.changeCatalog(CatalogUtils.java:34) real sql: select * from query_task where status = 0 2015-12-13 19:11:02 [ main:20574 ] - [ DEBUG ] org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:435) Executing SQL query [select * from query_task where status = 0] threadId===1 2015-12-13 19:11:03 [ main:21729 ] - [ DEBUG ] org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:246) Returning cached instance of singleton bean 'transactionManager' 2015-12-13 19:11:03 [ main:21729 ] - [ DEBUG ] org.springframework.transaction.support.AbstractPlatformTransactionManager.handleExistingTransaction(AbstractPlatformTransactionManager.java:471) Participating in existing transaction 2015-12-13 19:11:03 [ main:21729 ] - [ DEBUG ] org.crazycake.jdbcTemplateTool.utils.CatalogUtils.changeCatalog(CatalogUtils.java:34) real sql: select * from query_task where status = 0 2015-12-13 19:11:03 [ main:21729 ] - [ DEBUG ] org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:435) Executing SQL query [select * from query_task where status = 0] threadId===1 2015-12-13 19:11:04 [ main:22636 ] - [ DEBUG ] org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:246) Returning cached instance of singleton bean 'transactionManager' 2015-12-13 19:11:04 [ main:22636 ] - [ DEBUG ] org.springframework.transaction.support.AbstractPlatformTransactionManager.handleExistingTransaction(AbstractPlatformTransactionManager.java:471) Participating in existing transaction 2015-12-13 19:11:04 [ main:22636 ] - [ DEBUG ] org.crazycake.jdbcTemplateTool.utils.CatalogUtils.changeCatalog(CatalogUtils.java:34) real sql: select * from query_task where status = 0 2015-12-13 19:11:04 [ main:22636 ] - [ DEBUG ] org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:435) Executing SQL query [select * from query_task where status = 0] threadId===1 2015-12-13 19:11:05 [ main:23466 ] - [ DEBUG ] org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:246) Returning cached instance of singleton bean 'transactionManager' 2015-12-13 19:11:05 [ main:23466 ] - [ DEBUG ] org.springframework.transaction.support.AbstractPlatformTransactionManager.handleExistingTransaction(AbstractPlatformTransactionManager.java:471) Participating in existing transaction 2015-12-13 19:11:05 [ main:23466 ] - [ DEBUG ] org.crazycake.jdbcTemplateTool.utils.CatalogUtils.changeCatalog(CatalogUtils.java:34) real sql: select * from query_task where status = 0 2015-12-13 19:11:05 [ main:23466 ] - [ DEBUG ] org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:435) Executing SQL query [select * from query_task where status = 0] threadId===1 2015-12-13 19:11:05 [ main:24261 ] - [ DEBUG ] org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:246) Returning cached instance of singleton bean 'transactionManager' 2015-12-13 19:11:05 [ main:24261 ] - [ DEBUG ] org.springframework.transaction.support.AbstractPlatformTransactionManager.handleExistingTransaction(AbstractPlatformTransactionManager.java:471) Participating in existing transaction 2015-12-13 19:11:05 [ main:24261 ] - [ DEBUG ] org.crazycake.jdbcTemplateTool.utils.CatalogUtils.changeCatalog(CatalogUtils.java:34) real sql: select * from query_task where status = 0 2015-12-13 19:11:05 [ main:24261 ] - [ DEBUG ] org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:435) Executing SQL query [select * from query_task where status = 0] threadId===1 2015-12-13 19:11:06 [ main:25208 ] - [ DEBUG ] org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:246) Returning cached instance of singleton bean 'transactionManager' 2015-12-13 19:11:06 [ main:25208 ] - [ DEBUG ] org.springframework.transaction.support.AbstractPlatformTransactionManager.handleExistingTransaction(AbstractPlatformTransactionManager.java:471) Participating in existing transaction 2015-12-13 19:11:06 [ main:25208 ] - [ DEBUG ] org.crazycake.jdbcTemplateTool.utils.CatalogUtils.changeCatalog(CatalogUtils.java:34) real sql: select * from query_task where status = 0 2015-12-13 19:11:06 [ main:25208 ] - [ DEBUG ] org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:435) Executing SQL query [select * from query_task where status = 0] threadId===1 2015-12-13 19:11:07 [ main:26066 ] - [ DEBUG ] org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:246) Returning cached instance of singleton bean 'transactionManager' 2015-12-13 19:11:07 [ main:26066 ] - [ DEBUG ] org.springframework.transaction.support.AbstractPlatformTransactionManager.handleExistingTransaction(AbstractPlatformTransactionManager.java:471) Participating in existing transaction 2015-12-13 19:11:07 [ main:26066 ] - [ DEBUG ] org.crazycake.jdbcTemplateTool.utils.CatalogUtils.changeCatalog(CatalogUtils.java:34) real sql: select * from query_task where status = 0 2015-12-13 19:11:07 [ main:26066 ] - [ DEBUG ] org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:435) Executing SQL query [select * from query_task where status = 0] threadId===1 threadId===1 2015-12-13 19:11:08 [ main:26941 ] - [ DEBUG ] org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:435) Executing SQL query [select * from website] threadId===1 2015-12-13 19:11:09 [ main:27956 ] - [ DEBUG ] org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:753) Initiating transaction commit 2015-12-13 19:11:09 [ main:27972 ] - [ DEBUG ] org.springframework.jdbc.datasource.DataSourceTransactionManager.doCommit(DataSourceTransactionManager.java:265) Committing JDBC transaction on Connection [, MySQL Connector Java] 2015-12-13 19:11:09 [ main:28022 ] - [ DEBUG ] org.springframework.jdbc.datasource.DataSourceTransactionManager.doCleanupAfterCompletion(DataSourceTransactionManager.java:323) Releasing JDBC Connection [, MySQL Connector Java] after transaction 2015-12-13 19:11:09 [ main:28022 ] - [ DEBUG ] org.springframework.jdbc.datasource.DataSourceUtils.doReleaseConnection(DataSourceUtils.java:328) Returning JDBC Connection to DataSource
for(int i=0;i<4;i++){ executorService.submit(new Callable<String>() { public String call() throws Exception { System.out.println("ThreadId==="+Thread.currentThread().getId()); //Creating new transaction with name //同一个线程缓存的同一个connection //每一次Creating new transaction serviceUtil.queryTasks(); return sql; }; }); } //Connection conn = DataSourceUtils.getConnection(jdbcTemplate.getDataSource()); /*for(int i=0;i<8;i++){ //使用当前的 transaction serviceUtil.queryTasks(); }*/ System.out.println("threadId==="+Thread.currentThread().getId()); return jdbcTemplate.queryForList(sql);
2015-12-13 19:14:25 [ main:3880 ] - [ DEBUG ] org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:246) Returning cached instance of singleton bean 'transactionManager' 2015-12-13 19:14:25 [ main:3896 ] - [ DEBUG ] org.springframework.transaction.support.AbstractPlatformTransactionManager.getTransaction(AbstractPlatformTransactionManager.java:366) Creating new transaction with name [com.zzm.spider.dao.impl.BasicDaoImpl2.queryForListMap]: PROPAGATION_REQUIRED,ISOLATION_DEFAULT; '',-java.lang.Exception 2015-12-13 19:14:29 [ main:7517 ] - [ DEBUG ] org.springframework.jdbc.datasource.DataSourceTransactionManager.doBegin(DataSourceTransactionManager.java:205) Acquired Connection [, MySQL Connector Java] for JDBC transaction 2015-12-13 19:14:29 [ main:7533 ] - [ DEBUG ] org.springframework.jdbc.datasource.DataSourceTransactionManager.doBegin(DataSourceTransactionManager.java:222) Switching JDBC Connection [, MySQL Connector Java] to manual commit threadId===1 ThreadId===10 2015-12-13 19:14:29 [ pool-1-thread-1:7565 ] - [ DEBUG ] org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:246) Returning cached instance of singleton bean 'transactionManager' 2015-12-13 19:14:29 [ pool-1-thread-1:7565 ] - [ DEBUG ] org.springframework.transaction.support.AbstractPlatformTransactionManager.getTransaction(AbstractPlatformTransactionManager.java:366) Creating new transaction with name [com.zzm.spider.util.ServiceUtil.queryTasks]: PROPAGATION_REQUIRED,ISOLATION_DEFAULT; '',-java.lang.Exception 2015-12-13 19:14:29 [ main:7565 ] - [ DEBUG ] org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:435) Executing SQL query [select * from website] threadId===1 2015-12-13 19:14:29 [ pool-1-thread-1:7580 ] - [ DEBUG ] org.springframework.jdbc.datasource.DataSourceTransactionManager.doBegin(DataSourceTransactionManager.java:205) Acquired Connection [, MySQL Connector Java] for JDBC transaction 2015-12-13 19:14:29 [ pool-1-thread-1:7596 ] - [ DEBUG ] org.springframework.jdbc.datasource.DataSourceTransactionManager.doBegin(DataSourceTransactionManager.java:222) Switching JDBC Connection [, MySQL Connector Java] to manual commit 2015-12-13 19:14:29 [ main:7690 ] - [ DEBUG ] org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:753) Initiating transaction commit 2015-12-13 19:14:29 [ main:7690 ] - [ DEBUG ] org.springframework.jdbc.datasource.DataSourceTransactionManager.doCommit(DataSourceTransactionManager.java:265) Committing JDBC transaction on Connection [, MySQL Connector Java] 2015-12-13 19:14:29 [ pool-1-thread-1:7736 ] - [ DEBUG ] org.crazycake.jdbcTemplateTool.utils.CatalogUtils.changeCatalog(CatalogUtils.java:34) real sql: select * from query_task where status = 0 2015-12-13 19:14:29 [ pool-1-thread-1:7736 ] - [ DEBUG ] org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:435) Executing SQL query [select * from query_task where status = 0] threadId===10 2015-12-13 19:14:29 [ main:7736 ] - [ DEBUG ] org.springframework.jdbc.datasource.DataSourceTransactionManager.doCleanupAfterCompletion(DataSourceTransactionManager.java:323) Releasing JDBC Connection [, MySQL Connector Java] after transaction 2015-12-13 19:14:29 [ main:7736 ] - [ DEBUG ] org.springframework.jdbc.datasource.DataSourceUtils.doReleaseConnection(DataSourceUtils.java:328) Returning JDBC Connection to DataSource {id=1, fid=1, site_name=新浪微博, login_url=https://login.sina.com.cn/signup/signin.php?entry=homepage, post_url=null, login_userame_xpath=//input[@name='username'], login_userpassword_xpath=//input[@name='password'], login_loginsubmit_xpath=//input[@class='btn_submit_m'], login_verifcode_xpath=//img[@id='check_img'], login_verifcodeinput_xpath=//input[@id='door'], post_verifcode_xpath=null, postcontent_xpath=null, posttitle_xpath=null, postbutton_xpath=null, loginsuccess_code=http://club.history.sina.com.cn/my.php, postcontent_div_xpath=null, replytitle_xpath=null, replycontent_xpath=null, reply_button=null, postcontent_iframe_xpath=null, replycontent_iframe_xpath=null, replycontent_div_xpath=null, login_check=1, post_verifcode_button=null, post_verifcodeinput_xpath=null, reply_verifcode_xpath=null, reply_verifcodeinput_xpath=null, reply_verifcode_button=null, post_confirm_button=null, rfid=null, post_class=null, update_time=null, type=4, create_time=null, status=true} 2015-12-13 19:14:29 [ pool-1-thread-1:7768 ] - [ DEBUG ] org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:753) Initiating transaction commit 2015-12-13 19:14:29 [ pool-1-thread-1:7783 ] - [ DEBUG ] org.springframework.jdbc.datasource.DataSourceTransactionManager.doCommit(DataSourceTransactionManager.java:265) Committing JDBC transaction on Connection [, MySQL Connector Java] 2015-12-13 19:14:29 [ pool-1-thread-1:7830 ] - [ DEBUG ] org.springframework.jdbc.datasource.DataSourceTransactionManager.doCleanupAfterCompletion(DataSourceTransactionManager.java:323) Releasing JDBC Connection [, MySQL Connector Java] after transaction 2015-12-13 19:14:29 [ pool-1-thread-1:7830 ] - [ DEBUG ] org.springframework.jdbc.datasource.DataSourceUtils.doReleaseConnection(DataSourceUtils.java:328) Returning JDBC Connection to DataSource ThreadId===10 2015-12-13 19:14:29 [ pool-1-thread-1:7830 ] - [ DEBUG ] org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:246) Returning cached instance of singleton bean 'transactionManager' 2015-12-13 19:14:29 [ pool-1-thread-1:7830 ] - [ DEBUG ] org.springframework.transaction.support.AbstractPlatformTransactionManager.getTransaction(AbstractPlatformTransactionManager.java:366) Creating new transaction with name [com.zzm.spider.util.ServiceUtil.queryTasks]: PROPAGATION_REQUIRED,ISOLATION_DEFAULT; '',-java.lang.Exception 2015-12-13 19:14:29 [ pool-1-thread-1:7830 ] - [ DEBUG ] org.springframework.jdbc.datasource.DataSourceTransactionManager.doBegin(DataSourceTransactionManager.java:205) Acquired Connection [, MySQL Connector Java] for JDBC transaction 2015-12-13 19:14:29 [ pool-1-thread-1:7846 ] - [ DEBUG ] org.springframework.jdbc.datasource.DataSourceTransactionManager.doBegin(DataSourceTransactionManager.java:222) Switching JDBC Connection [, MySQL Connector Java] to manual commit 2015-12-13 19:14:29 [ pool-1-thread-1:7877 ] - [ DEBUG ] org.crazycake.jdbcTemplateTool.utils.CatalogUtils.changeCatalog(CatalogUtils.java:34) real sql: select * from query_task where status = 0 2015-12-13 19:14:29 [ pool-1-thread-1:7877 ] - [ DEBUG ] org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:435) Executing SQL query [select * from query_task where status = 0] threadId===10 2015-12-13 19:14:29 [ pool-1-thread-1:7970 ] - [ DEBUG ] org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:753) Initiating transaction commit 2015-12-13 19:14:29 [ pool-1-thread-1:7986 ] - [ DEBUG ] org.springframework.jdbc.datasource.DataSourceTransactionManager.doCommit(DataSourceTransactionManager.java:265) Committing JDBC transaction on Connection [, MySQL Connector Java] 2015-12-13 19:14:29 [ pool-1-thread-1:8048 ] - [ DEBUG ] org.springframework.jdbc.datasource.DataSourceTransactionManager.doCleanupAfterCompletion(DataSourceTransactionManager.java:323) Releasing JDBC Connection [, MySQL Connector Java] after transaction 2015-12-13 19:14:29 [ pool-1-thread-1:8048 ] - [ DEBUG ] org.springframework.jdbc.datasource.DataSourceUtils.doReleaseConnection(DataSourceUtils.java:328) Returning JDBC Connection to DataSource ThreadId===10 2015-12-13 19:14:29 [ pool-1-thread-1:8048 ] - [ DEBUG ] org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:246) Returning cached instance of singleton bean 'transactionManager' 2015-12-13 19:14:29 [ pool-1-thread-1:8048 ] - [ DEBUG ] org.springframework.transaction.support.AbstractPlatformTransactionManager.getTransaction(AbstractPlatformTransactionManager.java:366) Creating new transaction with name [com.zzm.spider.util.ServiceUtil.queryTasks]: PROPAGATION_REQUIRED,ISOLATION_DEFAULT; '',-java.lang.Exception 2015-12-13 19:14:29 [ pool-1-thread-1:8064 ] - [ DEBUG ] org.springframework.jdbc.datasource.DataSourceTransactionManager.doBegin(DataSourceTransactionManager.java:205) Acquired Connection [, MySQL Connector Java] for JDBC transaction 2015-12-13 19:14:29 [ pool-1-thread-1:8064 ] - [ DEBUG ] org.springframework.jdbc.datasource.DataSourceTransactionManager.doBegin(DataSourceTransactionManager.java:222) Switching JDBC Connection [, MySQL Connector Java] to manual commit 2015-12-13 19:14:29 [ pool-1-thread-1:8095 ] - [ DEBUG ] org.crazycake.jdbcTemplateTool.utils.CatalogUtils.changeCatalog(CatalogUtils.java:34) real sql: select * from query_task where status = 0 2015-12-13 19:14:29 [ pool-1-thread-1:8095 ] - [ DEBUG ] org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:435) Executing SQL query [select * from query_task where status = 0] threadId===10 2015-12-13 19:14:29 [ pool-1-thread-1:8111 ] - [ DEBUG ] org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:753) Initiating transaction commit 2015-12-13 19:14:29 [ pool-1-thread-1:8126 ] - [ DEBUG ] org.springframework.jdbc.datasource.DataSourceTransactionManager.doCommit(DataSourceTransactionManager.java:265) Committing JDBC transaction on Connection [, MySQL Connector Java] 2015-12-13 19:14:29 [ pool-1-thread-1:8204 ] - [ DEBUG ] org.springframework.jdbc.datasource.DataSourceTransactionManager.doCleanupAfterCompletion(DataSourceTransactionManager.java:323) Releasing JDBC Connection [, MySQL Connector Java] after transaction 2015-12-13 19:14:29 [ pool-1-thread-1:8204 ] - [ DEBUG ] org.springframework.jdbc.datasource.DataSourceUtils.doReleaseConnection(DataSourceUtils.java:328) Returning JDBC Connection to DataSource ThreadId===10 2015-12-13 19:14:29 [ pool-1-thread-1:8204 ] - [ DEBUG ] org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:246) Returning cached instance of singleton bean 'transactionManager' 2015-12-13 19:14:29 [ pool-1-thread-1:8204 ] - [ DEBUG ] org.springframework.transaction.support.AbstractPlatformTransactionManager.getTransaction(AbstractPlatformTransactionManager.java:366) Creating new transaction with name [com.zzm.spider.util.ServiceUtil.queryTasks]: PROPAGATION_REQUIRED,ISOLATION_DEFAULT; '',-java.lang.Exception 2015-12-13 19:14:29 [ pool-1-thread-1:8220 ] - [ DEBUG ] org.springframework.jdbc.datasource.DataSourceTransactionManager.doBegin(DataSourceTransactionManager.java:205) Acquired Connection [, MySQL Connector Java] for JDBC transaction 2015-12-13 19:14:30 [ pool-1-thread-1:8236 ] - [ DEBUG ] org.springframework.jdbc.datasource.DataSourceTransactionManager.doBegin(DataSourceTransactionManager.java:222) Switching JDBC Connection [, MySQL Connector Java] to manual commit 2015-12-13 19:14:30 [ pool-1-thread-1:8251 ] - [ DEBUG ] org.crazycake.jdbcTemplateTool.utils.CatalogUtils.changeCatalog(CatalogUtils.java:34) real sql: select * from query_task where status = 0 2015-12-13 19:14:30 [ pool-1-thread-1:8251 ] - [ DEBUG ] org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:435) Executing SQL query [select * from query_task where status = 0] threadId===10 2015-12-13 19:14:30 [ pool-1-thread-1:8282 ] - [ DEBUG ] org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:753) Initiating transaction commit 2015-12-13 19:14:30 [ pool-1-thread-1:8282 ] - [ DEBUG ] org.springframework.jdbc.datasource.DataSourceTransactionManager.doCommit(DataSourceTransactionManager.java:265) Committing JDBC transaction on Connection [, MySQL Connector Java] 2015-12-13 19:14:30 [ pool-1-thread-1:8345 ] - [ DEBUG ] org.springframework.jdbc.datasource.DataSourceTransactionManager.doCleanupAfterCompletion(DataSourceTransactionManager.java:323) Releasing JDBC Connection [, MySQL Connector Java] after transaction 2015-12-13 19:14:30 [ pool-1-thread-1:8345 ] - [ DEBUG ] org.springframework.jdbc.datasource.DataSourceUtils.doReleaseConnection(DataSourceUtils.java:328) Returning JDBC Connection to DataSource
相关推荐
### Spring事务与数据库操作 #### 一、Spring的声明式事务管理 在现代软件开发中,事务处理是非常关键的一部分,特别是在涉及多个数据操作时。Spring框架提供了强大的事务管理能力,可以方便地集成到应用程序中。...
本资源包提供了进行Spring事务管理开发所需的所有关键库,包括框架基础、核心组件、AOP(面向切面编程)支持、日志处理、编译工具以及与数据库交互的相关jar包。下面将对这些知识点进行详细解释: 1. **Spring框架*...
Spring事务机制是Java开发中非常重要的一个概念,它在企业级应用中扮演着核心角色,确保数据的一致性和完整性。Spring提供了多种事务管理方式,包括编程式事务管理和声明式事务管理。在这篇DEMO中,我们将重点探讨...
AOP 的核心是 aspect,它封装了特定的关注点,比如日志记录、安全性检查或事务管理,并允许在运行时把这些关注点与业务逻辑相织入。 Spring 框架中的事务管理分为两种主要方式:编程式事务管理和声明式事务管理。 ...
`spring-aop.jar`是Spring的AOP模块,它允许开发者定义切面,实现横切关注点,如事务管理、日志记录等。AOP是Spring中用于解耦关注点的一个重要工具,它使得业务逻辑代码无需直接处理这些通用任务。 Spring的DAO...
### AOP与Spring事务处理详解 #### 一、引言:为什么使用框架和设计模式? 在软件开发领域,设计模式和框架是两个重要的概念。设计模式作为一种指导思想,能够帮助开发者更好地解决常见的软件设计问题,确保系统...
- **Spring AOP**:Spring AOP允许开发者将一些通用的业务逻辑(例如日志、事务管理等)从业务代码中抽离出来,形成一个独立的部分,即切面(Aspect)。这样做的好处是可以减少业务代码的耦合度,提高代码的可读性...
本练习主要涵盖了Spring的三个方面:面向切面编程(AOP)、JDBC(Java Database Connectivity)以及事务管理(TX)。让我们详细探讨这些知识点。 1. **Spring AOP(面向切面编程)** 面向切面编程是Spring框架的一...
在Spring框架中,事务管理是核心特性之一,用于确保数据操作的一致性和完整性。当一个方法(A方法)内部调用另一个方法(B方法)时,可能会遇到事务控制...这个示例代码对于理解和调试Spring事务管理的问题非常有帮助。
AOP是一种编程范式,它可以将横切关注点(如日志记录、安全控制和事务管理)从业务逻辑中分离出来。借助Spring AOP,开发者可以通过声明式的方式使用企业级服务,比如安全性服务、事务服务等。 - **AOP的优势**: ...
Spring事务传播属性是这一机制的关键组成部分,它定义了在一个事务方法被另一个事务方法调用时,应该如何处理事务的边界。在深入理解Spring事务传播属性之前,我们首先需要了解Spring中的事务管理模型,包括编程式...
AOP是Spring框架的一个重要特性,允许我们在不修改源代码的情况下,通过"切面"来关注代码中的横切关注点,如事务管理、日志记录等。我们可以创建一个切面类,使用`@Aspect`注解,并在其中定义通知(advice),如`@...
例如,我们可以创建一个通知(Advice)来记录事务日志或处理其他与事务相关的任务。 在实际项目中,声明式事务管理更为常见,因为它降低了代码的耦合度,提高了可维护性。要启用声明式事务管理,我们需要在Spring...
Spring事务介绍,分23类进行梳理 Spring事务是指在Spring框架中对事务的支持和管理。事务是指一系列的操作,作为一个单元一起执行,如果其中任何一个操作失败,整个事务将被回滚。在Spring中,事务可以分为23类,...
例如,可能会有一个自定义的MyBatis拦截器用于分页查询,一个Spring AOP切面用于记录操作日志,Spring事务管理确保数据的一致性,而反射工具类可能用于动态加载配置或处理某些通用的反射任务。通过这些组件的组合,...
对于Spring事务管理,我们通常有两种方式:编程式和声明式。编程式事务管理需要在代码中显式地调用begin、commit、rollback等事务控制方法,而声明式事务管理则是在配置文件或注解中声明事务规则,更加简洁且易于...
本教程主要聚焦于Spring框架的两大核心特性:Spring AOP(面向切面编程)和Spring事务处理,通过具体的应用案例来深入理解这两个概念。 首先,让我们详细探讨Spring AOP。AOP是面向切面编程的缩写,它允许程序员...
最后,`spring-tx.jar`提供事务管理支持,无论是编程式还是声明式的事务管理,都可以通过日志查看其处理过程。 通过分析这些日志,开发者不仅能了解Spring的内部机制,还能定位问题,优化性能,提升应用的稳定性和...