论坛首页 Java企业应用论坛

spring servlet jdbc

浏览 3187 次
精华帖 (0) :: 良好帖 (0) :: 新手帖 (12) :: 隐藏帖 (0)
作者 正文
   发表时间:2009-12-05   最后修改:2009-12-07

这个文章的关注点是如何在只准使用servlet jsp jdbc的情况下 加入spring来简化 jdbc代码 事务控制 依赖注入

 

web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
	http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
	<welcome-file-list>
		<welcome-file>index.jsp</welcome-file>
	</welcome-file-list>
	<filter>
		<filter-name>WebFilter</filter-name>
		<filter-class>
			org.springframework.web.filter.DelegatingFilterProxy
		</filter-class>
		<init-param>
			<param-name>targetFilterLifecycle</param-name>
			<param-value>true</param-value>
		</init-param>
	</filter>

	<filter-mapping>
		<filter-name>WebFilter</filter-name>
		<url-pattern>/*</url-pattern>
	</filter-mapping>
	<context-param>
		<param-name>contextConfigLocation</param-name>
		<param-value>
			/WEB-INF/applicationContext-*.xml,classpath*:applicationContext-*.xml
		</param-value>
	</context-param>

	<listener>
		<listener-class>
			org.springframework.web.context.ContextLoaderListener
		</listener-class>
	</listener>
</web-app>

 applicationContext.xml

<?xml version="1.0" encoding="UTF-8"?>

<!--
	- Application context definition for JPetStore's business layer.
	- Contains bean references to the transaction manager and to the DAOs in
	- dataAccessContext-local/jta.xml (see web.xml's "contextConfigLocation").
-->
<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.0.xsd
           http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd
           http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd">
	<bean id="WebFilter" class="test.spring.WebFilter">
		<property name="manageSupport" ref="manageSupport" />
	</bean>

	<bean id="manageSupport" class="test.spring.ManageSupport">
		<property name="name" value="bingo" />
		<property name="jdbcTemplate" ref="jdbcTemplate"></property>
	</bean>

    <bean id="jdbcTemplate" class="org.springframework.jdbc.core.simple.SimpleJdbcTemplate">
    <constructor-arg>
        <ref bean="dataSource"/>
    </constructor-arg>
    </bean>

	<bean id="dataSource"
		class="org.apache.commons.dbcp.BasicDataSource"
		destroy-method="close">
		<property name="driverClassName" value="net.sourceforge.jtds.jdbc.Driver" />
		<property name="url" value="jdbc:jtds:sqlserver://127.0.0.1:1433/xxx" />
		<property name="username" value="sa" />
		<property name="password" value="sa" />
	</bean>
</beans>

 

WebFilter.java

package test.spring;

import java.io.IOException;

import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;

public class WebFilter implements Filter {

    private ManageSupport manageSupport;

    public void destroy() {
        // TODO Auto-generated method stub

    }

    public void doFilter(ServletRequest arg0, ServletResponse arg1, FilterChain arg2) throws IOException, ServletException {
        System.out.println(getClass().getName() + " filter");
        System.out.println(manageSupport.getName());
        int count = manageSupport.getJdbcTemplate().queryForInt("SELECT COUNT(*) FROM MESSAGE");
        System.out.println(count);
        arg2.doFilter(arg0, arg1);
        HttpServletRequest req = (HttpServletRequest) arg0;
        req.getSession().getServletContext().getRequestDispatcher("/index2.jsp").forward(arg0, arg1);

    }

    public void init(FilterConfig arg0) throws ServletException {
        // TODO Auto-generated method stub

    }

    public ManageSupport getManageSupport() {
        return manageSupport;
    }

    public void setManageSupport(ManageSupport manageSupport) {
        this.manageSupport = manageSupport;
    }

}

 

ManageSupport.java

package test.spring;

import org.springframework.jdbc.core.simple.SimpleJdbcTemplate;

public class ManageSupport{
    
    private SimpleJdbcTemplate jdbcTemplate;
    private String name;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public SimpleJdbcTemplate getJdbcTemplate() {
        return jdbcTemplate;
    }

    public void setJdbcTemplate(SimpleJdbcTemplate jdbcTemplate) {
        this.jdbcTemplate = jdbcTemplate;
    }
}

 事物控制在spring的sample里有参考

 

研究了一下事物

改动如下

打算针对ManageSupport做自动事物切入

把ManageSupport重构出接口 用eclipse可以在几秒实现这个

package test.spring;

import org.springframework.jdbc.core.simple.SimpleJdbcTemplate;

public interface IManageSupport {

    public abstract String getName();

    public abstract void setName(String name);

    public abstract SimpleJdbcTemplate getJdbcTemplate();

    public abstract void setJdbcTemplate(SimpleJdbcTemplate jdbcTemplate);
    public int logic1();
    public void logic2();
}

 

在实现中的事物逻辑

public int logic1(){
        return getJdbcTemplate().queryForInt("SELECT COUNT(*) FROM JB_COM_MESSAGE");
    }
    
    public void logic2(){
        int count=logic1();
        for (int i = 1; i <= count; i++) {
            getJdbcTemplate().update("update JB_COM_MESSAGE set m_level =1 where id=?", i);
        }
    }

 调用业务方法的方法  WebFilter.java中的

public void doFilter(ServletRequest arg0, ServletResponse arg1, FilterChain arg2) throws IOException, ServletException {
        System.out.println(getClass().getName() + " filter");
        System.out.println(manageSupport.getName());
        int count = manageSupport.logic1();
        System.out.println(count);
        manageSupport.logic2();
        arg2.doFilter(arg0, arg1);
        HttpServletRequest req = (HttpServletRequest) arg0;
        req.getSession().getServletContext().getRequestDispatcher("/index2.jsp").forward(arg0, arg1);
    }

 

spring配置中 事务相关

 <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
  <property name="dataSource" ref="dataSource" />
 </bean>

 <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
  <property name="driverClassName" value="net.sourceforge.jtds.jdbc.Driver" />
  <property name="url" value="jdbc:jtds:sqlserver://127.0.0.1:1433/DSO" />
  <property name="username" value="sa" />
  <property name="password" value="sa" />
 </bean>

 <aop:config>
  <aop:advisor pointcut="execution(* test.spring.IManageSupport.*(..))" advice-ref="txAdvice" />
 </aop:config>
 
 <tx:advice id="txAdvice">
  <tx:attributes>
   <tx:method name="logic*" propagation="REQUIRED" />
  </tx:attributes>
 </tx:advice>

 

最后执行成功 以下是log

test.spring.WebFilter filter
[DEBUG] 2009-12-07 10:26:45 [http-8080-Processor25] [org.springframework.transaction.interceptor.TransactionInterceptor.prepareTransactionInfo:300]  Don't need to create transaction for [test.spring.IManageSupport.getName]: This method isn't transactional.
bingo
[DEBUG] 2009-12-07 10:26:45 [http-8080-Processor25] [org.springframework.jdbc.datasource.DataSourceTransactionManager.getTransaction:371]  Creating new transaction with name [test.spring.IManageSupport.logic1]: PROPAGATION_REQUIRED,ISOLATION_DEFAULT
[DEBUG] 2009-12-07 10:26:45 [http-8080-Processor25] [org.springframework.jdbc.datasource.DataSourceTransactionManager.doBegin:202]  Acquired Connection [jdbc:jtds:sqlserver://127.0.0.1:1433/DSO, UserName=sa, jTDS Type 4 JDBC Driver for MS SQL Server and Sybase] for JDBC transaction
[DEBUG] 2009-12-07 10:26:46 [http-8080-Processor25] [org.springframework.jdbc.datasource.DataSourceTransactionManager.doBegin:219]  Switching JDBC Connection [jdbc:jtds:sqlserver://127.0.0.1:1433/DSO, UserName=sa, jTDS Type 4 JDBC Driver for MS SQL Server and Sybase] to manual commit
[DEBUG] 2009-12-07 10:26:46 [http-8080-Processor25] [org.springframework.transaction.support.TransactionSynchronizationManager.bindResource:186]  Bound value [org.springframework.jdbc.datasource.ConnectionHolder@6f0962] for key [org.apache.commons.dbcp.BasicDataSource@17e9134] to thread [http-8080-Processor25]
[DEBUG] 2009-12-07 10:26:46 [http-8080-Processor25] [org.springframework.transaction.support.TransactionSynchronizationManager.initSynchronization:261]  Initializing transaction synchronization
[DEBUG] 2009-12-07 10:26:46 [http-8080-Processor25] [org.springframework.transaction.interceptor.TransactionInterceptor.prepareTransactionInfo:290]  Getting transaction for [test.spring.IManageSupport.logic1]
[DEBUG] 2009-12-07 10:26:46 [http-8080-Processor25] [org.springframework.jdbc.core.JdbcTemplate.query:436]  Executing SQL query [SELECT COUNT(*) FROM JB_COM_MESSAGE]
[DEBUG] 2009-12-07 10:26:46 [http-8080-Processor25] [org.springframework.transaction.support.TransactionSynchronizationManager.getResource:142]  Retrieved value [org.springframework.jdbc.datasource.ConnectionHolder@6f0962] for key [org.apache.commons.dbcp.BasicDataSource@17e9134] bound to thread [http-8080-Processor25]
[DEBUG] 2009-12-07 10:26:46 [http-8080-Processor25] [org.springframework.transaction.support.TransactionSynchronizationManager.getResource:142]  Retrieved value [org.springframework.jdbc.datasource.ConnectionHolder@6f0962] for key [org.apache.commons.dbcp.BasicDataSource@17e9134] bound to thread [http-8080-Processor25]
[DEBUG] 2009-12-07 10:26:46 [http-8080-Processor25] [org.springframework.transaction.support.TransactionSynchronizationManager.getResource:142]  Retrieved value [org.springframework.jdbc.datasource.ConnectionHolder@6f0962] for key [org.apache.commons.dbcp.BasicDataSource@17e9134] bound to thread [http-8080-Processor25]
[DEBUG] 2009-12-07 10:26:46 [http-8080-Processor25] [org.springframework.transaction.interceptor.TransactionInterceptor.commitTransactionAfterReturning:319]  Completing transaction for [test.spring.IManageSupport.logic1]
[DEBUG] 2009-12-07 10:26:46 [http-8080-Processor25] [org.springframework.jdbc.datasource.DataSourceTransactionManager.triggerBeforeCommit:903]  Triggering beforeCommit synchronization
[DEBUG] 2009-12-07 10:26:46 [http-8080-Processor25] [org.springframework.jdbc.datasource.DataSourceTransactionManager.triggerBeforeCompletion:916]  Triggering beforeCompletion synchronization
[DEBUG] 2009-12-07 10:26:46 [http-8080-Processor25] [org.springframework.jdbc.datasource.DataSourceTransactionManager.processCommit:730]  Initiating transaction commit
[DEBUG] 2009-12-07 10:26:46 [http-8080-Processor25] [org.springframework.jdbc.datasource.DataSourceTransactionManager.doCommit:259]  Committing JDBC transaction on Connection [jdbc:jtds:sqlserver://127.0.0.1:1433/DSO, UserName=sa, jTDS Type 4 JDBC Driver for MS SQL Server and Sybase]
[DEBUG] 2009-12-07 10:26:46 [http-8080-Processor25] [org.springframework.jdbc.datasource.DataSourceTransactionManager.triggerAfterCommit:929]  Triggering afterCommit synchronization
[DEBUG] 2009-12-07 10:26:46 [http-8080-Processor25] [org.springframework.jdbc.datasource.DataSourceTransactionManager.triggerAfterCompletion:945]  Triggering afterCompletion synchronization
[DEBUG] 2009-12-07 10:26:46 [http-8080-Processor25] [org.springframework.transaction.support.TransactionSynchronizationManager.clearSynchronization:315]  Clearing transaction synchronization
[DEBUG] 2009-12-07 10:26:46 [http-8080-Processor25] [org.springframework.transaction.support.TransactionSynchronizationManager.doUnbindResource:232]  Removed value [org.springframework.jdbc.datasource.ConnectionHolder@6f0962] for key [org.apache.commons.dbcp.BasicDataSource@17e9134] from thread [http-8080-Processor25]
[DEBUG] 2009-12-07 10:26:46 [http-8080-Processor25] [org.springframework.jdbc.datasource.DataSourceTransactionManager.doCleanupAfterCompletion:314]  Releasing JDBC Connection [jdbc:jtds:sqlserver://127.0.0.1:1433/DSO, UserName=sa, jTDS Type 4 JDBC Driver for MS SQL Server and Sybase] after transaction
[DEBUG] 2009-12-07 10:26:46 [http-8080-Processor25] [org.springframework.jdbc.datasource.DataSourceUtils.doReleaseConnection:312]  Returning JDBC Connection to DataSource
6
[DEBUG] 2009-12-07 10:26:46 [http-8080-Processor25] [org.springframework.jdbc.datasource.DataSourceTransactionManager.getTransaction:371]  Creating new transaction with name [test.spring.IManageSupport.logic2]: PROPAGATION_REQUIRED,ISOLATION_DEFAULT
[DEBUG] 2009-12-07 10:26:46 [http-8080-Processor25] [org.springframework.jdbc.datasource.DataSourceTransactionManager.doBegin:202]  Acquired Connection [jdbc:jtds:sqlserver://127.0.0.1:1433/DSO, UserName=sa, jTDS Type 4 JDBC Driver for MS SQL Server and Sybase] for JDBC transaction
[DEBUG] 2009-12-07 10:26:46 [http-8080-Processor25] [org.springframework.jdbc.datasource.DataSourceTransactionManager.doBegin:219]  Switching JDBC Connection [jdbc:jtds:sqlserver://127.0.0.1:1433/DSO, UserName=sa, jTDS Type 4 JDBC Driver for MS SQL Server and Sybase] to manual commit
[DEBUG] 2009-12-07 10:26:46 [http-8080-Processor25] [org.springframework.transaction.support.TransactionSynchronizationManager.bindResource:186]  Bound value [org.springframework.jdbc.datasource.ConnectionHolder@139a0dc] for key [org.apache.commons.dbcp.BasicDataSource@17e9134] to thread [http-8080-Processor25]
[DEBUG] 2009-12-07 10:26:46 [http-8080-Processor25] [org.springframework.transaction.support.TransactionSynchronizationManager.initSynchronization:261]  Initializing transaction synchronization
[DEBUG] 2009-12-07 10:26:46 [http-8080-Processor25] [org.springframework.transaction.interceptor.TransactionInterceptor.prepareTransactionInfo:290]  Getting transaction for [test.spring.IManageSupport.logic2]
[DEBUG] 2009-12-07 10:26:46 [http-8080-Processor25] [org.springframework.jdbc.core.JdbcTemplate.query:436]  Executing SQL query [SELECT COUNT(*) FROM JB_COM_MESSAGE]
[DEBUG] 2009-12-07 10:26:46 [http-8080-Processor25] [org.springframework.transaction.support.TransactionSynchronizationManager.getResource:142]  Retrieved value [org.springframework.jdbc.datasource.ConnectionHolder@139a0dc] for key [org.apache.commons.dbcp.BasicDataSource@17e9134] bound to thread [http-8080-Processor25]
[DEBUG] 2009-12-07 10:26:46 [http-8080-Processor25] [org.springframework.transaction.support.TransactionSynchronizationManager.getResource:142]  Retrieved value [org.springframework.jdbc.datasource.ConnectionHolder@139a0dc] for key [org.apache.commons.dbcp.BasicDataSource@17e9134] bound to thread [http-8080-Processor25]
[DEBUG] 2009-12-07 10:26:46 [http-8080-Processor25] [org.springframework.transaction.support.TransactionSynchronizationManager.getResource:142]  Retrieved value [org.springframework.jdbc.datasource.ConnectionHolder@139a0dc] for key [org.apache.commons.dbcp.BasicDataSource@17e9134] bound to thread [http-8080-Processor25]
[DEBUG] 2009-12-07 10:26:46 [http-8080-Processor25] [org.springframework.jdbc.core.JdbcTemplate.update:790]  Executing prepared SQL update
[DEBUG] 2009-12-07 10:26:46 [http-8080-Processor25] [org.springframework.jdbc.core.JdbcTemplate.execute:574]  Executing prepared SQL statement [update JB_COM_MESSAGE set m_level =1 where id=?]
[DEBUG] 2009-12-07 10:26:46 [http-8080-Processor25] [org.springframework.transaction.support.TransactionSynchronizationManager.getResource:142]  Retrieved value [org.springframework.jdbc.datasource.ConnectionHolder@139a0dc] for key [org.apache.commons.dbcp.BasicDataSource@17e9134] bound to thread [http-8080-Processor25]
[DEBUG] 2009-12-07 10:26:46 [http-8080-Processor25] [org.springframework.transaction.support.TransactionSynchronizationManager.getResource:142]  Retrieved value [org.springframework.jdbc.datasource.ConnectionHolder@139a0dc] for key [org.apache.commons.dbcp.BasicDataSource@17e9134] bound to thread [http-8080-Processor25]
[DEBUG] 2009-12-07 10:26:46 [http-8080-Processor25] [org.springframework.jdbc.core.StatementCreatorUtils.setParameterValueInternal:207]  Setting SQL statement parameter value: column index 1, parameter value [1], value class [java.lang.Integer], SQL type unknown
[DEBUG] 2009-12-07 10:26:46 [http-8080-Processor25] [org.springframework.jdbc.core.JdbcTemplate.doInPreparedStatement:800]  SQL update affected 1 rows
[DEBUG] 2009-12-07 10:26:46 [http-8080-Processor25] [org.springframework.transaction.support.TransactionSynchronizationManager.getResource:142]  Retrieved value [org.springframework.jdbc.datasource.ConnectionHolder@139a0dc] for key [org.apache.commons.dbcp.BasicDataSource@17e9134] bound to thread [http-8080-Processor25]
[DEBUG] 2009-12-07 10:26:46 [http-8080-Processor25] [org.springframework.jdbc.core.JdbcTemplate.update:790]  Executing prepared SQL update
[DEBUG] 2009-12-07 10:26:46 [http-8080-Processor25] [org.springframework.jdbc.core.JdbcTemplate.execute:574]  Executing prepared SQL statement [update JB_COM_MESSAGE set m_level =1 where id=?]
[DEBUG] 2009-12-07 10:26:46 [http-8080-Processor25] [org.springframework.transaction.support.TransactionSynchronizationManager.getResource:142]  Retrieved value [org.springframework.jdbc.datasource.ConnectionHolder@139a0dc] for key [org.apache.commons.dbcp.BasicDataSource@17e9134] bound to thread [http-8080-Processor25]
[DEBUG] 2009-12-07 10:26:46 [http-8080-Processor25] [org.springframework.transaction.support.TransactionSynchronizationManager.getResource:142]  Retrieved value [org.springframework.jdbc.datasource.ConnectionHolder@139a0dc] for key [org.apache.commons.dbcp.BasicDataSource@17e9134] bound to thread [http-8080-Processor25]
[DEBUG] 2009-12-07 10:26:46 [http-8080-Processor25] [org.springframework.jdbc.core.StatementCreatorUtils.setParameterValueInternal:207]  Setting SQL statement parameter value: column index 1, parameter value [2], value class [java.lang.Integer], SQL type unknown
[DEBUG] 2009-12-07 10:26:46 [http-8080-Processor25] [org.springframework.jdbc.core.JdbcTemplate.doInPreparedStatement:800]  SQL update affected 1 rows
[DEBUG] 2009-12-07 10:26:46 [http-8080-Processor25] [org.springframework.transaction.support.TransactionSynchronizationManager.getResource:142]  Retrieved value [org.springframework.jdbc.datasource.ConnectionHolder@139a0dc] for key [org.apache.commons.dbcp.BasicDataSource@17e9134] bound to thread [http-8080-Processor25]
[DEBUG] 2009-12-07 10:26:46 [http-8080-Processor25] [org.springframework.jdbc.core.JdbcTemplate.update:790]  Executing prepared SQL update
[DEBUG] 2009-12-07 10:26:46 [http-8080-Processor25] [org.springframework.jdbc.core.JdbcTemplate.execute:574]  Executing prepared SQL statement [update JB_COM_MESSAGE set m_level =1 where id=?]
[DEBUG] 2009-12-07 10:26:46 [http-8080-Processor25] [org.springframework.transaction.support.TransactionSynchronizationManager.getResource:142]  Retrieved value [org.springframework.jdbc.datasource.ConnectionHolder@139a0dc] for key [org.apache.commons.dbcp.BasicDataSource@17e9134] bound to thread [http-8080-Processor25]
[DEBUG] 2009-12-07 10:26:46 [http-8080-Processor25] [org.springframework.transaction.support.TransactionSynchronizationManager.getResource:142]  Retrieved value [org.springframework.jdbc.datasource.ConnectionHolder@139a0dc] for key [org.apache.commons.dbcp.BasicDataSource@17e9134] bound to thread [http-8080-Processor25]
[DEBUG] 2009-12-07 10:26:46 [http-8080-Processor25] [org.springframework.jdbc.core.StatementCreatorUtils.setParameterValueInternal:207]  Setting SQL statement parameter value: column index 1, parameter value [3], value class [java.lang.Integer], SQL type unknown
[DEBUG] 2009-12-07 10:26:46 [http-8080-Processor25] [org.springframework.jdbc.core.JdbcTemplate.doInPreparedStatement:800]  SQL update affected 1 rows
[DEBUG] 2009-12-07 10:26:46 [http-8080-Processor25] [org.springframework.transaction.support.TransactionSynchronizationManager.getResource:142]  Retrieved value [org.springframework.jdbc.datasource.ConnectionHolder@139a0dc] for key [org.apache.commons.dbcp.BasicDataSource@17e9134] bound to thread [http-8080-Processor25]
[DEBUG] 2009-12-07 10:26:46 [http-8080-Processor25] [org.springframework.jdbc.core.JdbcTemplate.update:790]  Executing prepared SQL update
[DEBUG] 2009-12-07 10:26:46 [http-8080-Processor25] [org.springframework.jdbc.core.JdbcTemplate.execute:574]  Executing prepared SQL statement [update JB_COM_MESSAGE set m_level =1 where id=?]
[DEBUG] 2009-12-07 10:26:46 [http-8080-Processor25] [org.springframework.transaction.support.TransactionSynchronizationManager.getResource:142]  Retrieved value [org.springframework.jdbc.datasource.ConnectionHolder@139a0dc] for key [org.apache.commons.dbcp.BasicDataSource@17e9134] bound to thread [http-8080-Processor25]
[DEBUG] 2009-12-07 10:26:46 [http-8080-Processor25] [org.springframework.transaction.support.TransactionSynchronizationManager.getResource:142]  Retrieved value [org.springframework.jdbc.datasource.ConnectionHolder@139a0dc] for key [org.apache.commons.dbcp.BasicDataSource@17e9134] bound to thread [http-8080-Processor25]
[DEBUG] 2009-12-07 10:26:46 [http-8080-Processor25] [org.springframework.jdbc.core.StatementCreatorUtils.setParameterValueInternal:207]  Setting SQL statement parameter value: column index 1, parameter value [4], value class [java.lang.Integer], SQL type unknown
[DEBUG] 2009-12-07 10:26:46 [http-8080-Processor25] [org.springframework.jdbc.core.JdbcTemplate.doInPreparedStatement:800]  SQL update affected 1 rows
[DEBUG] 2009-12-07 10:26:46 [http-8080-Processor25] [org.springframework.transaction.support.TransactionSynchronizationManager.getResource:142]  Retrieved value [org.springframework.jdbc.datasource.ConnectionHolder@139a0dc] for key [org.apache.commons.dbcp.BasicDataSource@17e9134] bound to thread [http-8080-Processor25]
[DEBUG] 2009-12-07 10:26:46 [http-8080-Processor25] [org.springframework.jdbc.core.JdbcTemplate.update:790]  Executing prepared SQL update
[DEBUG] 2009-12-07 10:26:46 [http-8080-Processor25] [org.springframework.jdbc.core.JdbcTemplate.execute:574]  Executing prepared SQL statement [update JB_COM_MESSAGE set m_level =1 where id=?]
[DEBUG] 2009-12-07 10:26:46 [http-8080-Processor25] [org.springframework.transaction.support.TransactionSynchronizationManager.getResource:142]  Retrieved value [org.springframework.jdbc.datasource.ConnectionHolder@139a0dc] for key [org.apache.commons.dbcp.BasicDataSource@17e9134] bound to thread [http-8080-Processor25]
[DEBUG] 2009-12-07 10:26:46 [http-8080-Processor25] [org.springframework.transaction.support.TransactionSynchronizationManager.getResource:142]  Retrieved value [org.springframework.jdbc.datasource.ConnectionHolder@139a0dc] for key [org.apache.commons.dbcp.BasicDataSource@17e9134] bound to thread [http-8080-Processor25]
[DEBUG] 2009-12-07 10:26:46 [http-8080-Processor25] [org.springframework.jdbc.core.StatementCreatorUtils.setParameterValueInternal:207]  Setting SQL statement parameter value: column index 1, parameter value [5], value class [java.lang.Integer], SQL type unknown
[DEBUG] 2009-12-07 10:26:46 [http-8080-Processor25] [org.springframework.jdbc.core.JdbcTemplate.doInPreparedStatement:800]  SQL update affected 1 rows
[DEBUG] 2009-12-07 10:26:46 [http-8080-Processor25] [org.springframework.transaction.support.TransactionSynchronizationManager.getResource:142]  Retrieved value [org.springframework.jdbc.datasource.ConnectionHolder@139a0dc] for key [org.apache.commons.dbcp.BasicDataSource@17e9134] bound to thread [http-8080-Processor25]
[DEBUG] 2009-12-07 10:26:46 [http-8080-Processor25] [org.springframework.jdbc.core.JdbcTemplate.update:790]  Executing prepared SQL update
[DEBUG] 2009-12-07 10:26:46 [http-8080-Processor25] [org.springframework.jdbc.core.JdbcTemplate.execute:574]  Executing prepared SQL statement [update JB_COM_MESSAGE set m_level =1 where id=?]
[DEBUG] 2009-12-07 10:26:46 [http-8080-Processor25] [org.springframework.transaction.support.TransactionSynchronizationManager.getResource:142]  Retrieved value [org.springframework.jdbc.datasource.ConnectionHolder@139a0dc] for key [org.apache.commons.dbcp.BasicDataSource@17e9134] bound to thread [http-8080-Processor25]
[DEBUG] 2009-12-07 10:26:46 [http-8080-Processor25] [org.springframework.transaction.support.TransactionSynchronizationManager.getResource:142]  Retrieved value [org.springframework.jdbc.datasource.ConnectionHolder@139a0dc] for key [org.apache.commons.dbcp.BasicDataSource@17e9134] bound to thread [http-8080-Processor25]
[DEBUG] 2009-12-07 10:26:46 [http-8080-Processor25] [org.springframework.jdbc.core.StatementCreatorUtils.setParameterValueInternal:207]  Setting SQL statement parameter value: column index 1, parameter value [6], value class [java.lang.Integer], SQL type unknown
[DEBUG] 2009-12-07 10:26:46 [http-8080-Processor25] [org.springframework.jdbc.core.JdbcTemplate.doInPreparedStatement:800]  SQL update affected 1 rows
[DEBUG] 2009-12-07 10:26:46 [http-8080-Processor25] [org.springframework.transaction.support.TransactionSynchronizationManager.getResource:142]  Retrieved value [org.springframework.jdbc.datasource.ConnectionHolder@139a0dc] for key [org.apache.commons.dbcp.BasicDataSource@17e9134] bound to thread [http-8080-Processor25]
[DEBUG] 2009-12-07 10:26:46 [http-8080-Processor25] [org.springframework.transaction.interceptor.TransactionInterceptor.commitTransactionAfterReturning:319]  Completing transaction for [test.spring.IManageSupport.logic2]
[DEBUG] 2009-12-07 10:26:46 [http-8080-Processor25] [org.springframework.jdbc.datasource.DataSourceTransactionManager.triggerBeforeCommit:903]  Triggering beforeCommit synchronization
[DEBUG] 2009-12-07 10:26:46 [http-8080-Processor25] [org.springframework.jdbc.datasource.DataSourceTransactionManager.triggerBeforeCompletion:916]  Triggering beforeCompletion synchronization
[DEBUG] 2009-12-07 10:26:46 [http-8080-Processor25] [org.springframework.jdbc.datasource.DataSourceTransactionManager.processCommit:730]  Initiating transaction commit
[DEBUG] 2009-12-07 10:26:46 [http-8080-Processor25] [org.springframework.jdbc.datasource.DataSourceTransactionManager.doCommit:259]  Committing JDBC transaction on Connection [jdbc:jtds:sqlserver://127.0.0.1:1433/DSO, UserName=sa, jTDS Type 4 JDBC Driver for MS SQL Server and Sybase]
[DEBUG] 2009-12-07 10:26:46 [http-8080-Processor25] [org.springframework.jdbc.datasource.DataSourceTransactionManager.triggerAfterCommit:929]  Triggering afterCommit synchronization
[DEBUG] 2009-12-07 10:26:46 [http-8080-Processor25] [org.springframework.jdbc.datasource.DataSourceTransactionManager.triggerAfterCompletion:945]  Triggering afterCompletion synchronization
[DEBUG] 2009-12-07 10:26:46 [http-8080-Processor25] [org.springframework.transaction.support.TransactionSynchronizationManager.clearSynchronization:315]  Clearing transaction synchronization
[DEBUG] 2009-12-07 10:26:46 [http-8080-Processor25] [org.springframework.transaction.support.TransactionSynchronizationManager.doUnbindResource:232]  Removed value [org.springframework.jdbc.datasource.ConnectionHolder@139a0dc] for key [org.apache.commons.dbcp.BasicDataSource@17e9134] from thread [http-8080-Processor25]
[DEBUG] 2009-12-07 10:26:46 [http-8080-Processor25] [org.springframework.jdbc.datasource.DataSourceTransactionManager.doCleanupAfterCompletion:314]  Releasing JDBC Connection [jdbc:jtds:sqlserver://127.0.0.1:1433/DSO, UserName=sa, jTDS Type 4 JDBC Driver for MS SQL Server and Sybase] after transaction
[DEBUG] 2009-12-07 10:26:46 [http-8080-Processor25] [org.springframework.jdbc.datasource.DataSourceUtils.doReleaseConnection:312]  Returning JDBC Connection to DataSource

 

 

   发表时间:2010-09-02  
无用信息太多,文章只显示关键代码就好,完整的可提供下载
0 请登录后投票
论坛首页 Java企业应用版

跳转论坛:
Global site tag (gtag.js) - Google Analytics