Announcement Announcement Module
Collapse
No announcement yet.
when the DB connection is borrowed from pool, and when it is returned to pool? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • when the DB connection is borrowed from pool, and when it is returned to pool?

    the scenario is:
    the code structure is:
    Code:
    package com.job.service;
    
    public interface JobManager{
        void insertJob(Job job);
        Job findJob(String jobID);
    }
    
    package com.job.service.impl;
    
    public class JobManagerImpl{
        private JobDao jobDao;
        //setter;
        public void insertJob(Job job){
            jobDao.insertJob(job);
        }
        
        public Job findJob(String jobID){
            return jobDao.findJob(jobID);
        }    
    }
    
    package com.job.dao;
    
    public interface JobDao{
        void insertJob(Job job);
        Job findJob(String jobID);
    }
    package com.job.dao.impl;
    
    public class JobDaoImpl extends SqlMapClientDaoSupport implements JobDao {     
        public void insertJob(Job job){
            //do insert
        }
        
        public Job findJob(String jobID){
            //do find
        }    
    }
    the Spring configuration
    Code:
    <aop:config proxy-target-class="true">
    	<aop:advisor
    		pointcut="execution(* com.job.service.impl.*.*(..))"
    		advice-ref="txAdvice" />
    </aop:config>
    
    <tx:advice id="txAdvice" transaction-manager="transactionManager">
        <tx:attributes>
        	<tx:method name="find*" read-only="true" />
        	<tx:method name="*" propagation="REQUIRED" rollback-for="Exception"/>
        </tx:attributes>
    </tx:advice>
    
    <bean id="jobManager" class="com.job.service.impl.JobManagerImpl">
        <property name="jobDao" ref="jobDao" />
    </bean>    
    
    <bean id="jobDao" class="com.job.dao.impl.JobManagerImpl">
        <property name="sqlMapClient" ref="sqlMapClient" />
    </bean>
    the first test case is like bellow, my question is:
    1. when the db connection is borrowed from the datasource(pool)? Is the db connction borrowed from the datasource at the moment of excuting the code jobManager.insertJob(job)?
    2. when the db connection is returned to pool? is the moment of exiting jobManager.insertJob(job)?
    3. when the db connection is returned to pool if the JobDao.insertJob(Job) throws an exception ?
    Code:
    Job job = new Job();
    //set values to job
    jobManager.insertJob(job);
    
    //do other
    the second test case is like bellow, my question is:
    1. when the db connection is borrowed from the datasource(pool)? Is the db connction borrowed from the datasource at the moment of excuting the code jobManager.findJob(jobId)?
    2. when the db connection is returned to pool? is the moment of exiting jobManager.findJob(jobId)?
    3. when the db connection is returned to pool if the JobDao.findJob(String JobId) throws an exception ?
    Code:
    Job job = jobManager.findJob(jobId);
    
    //do other
    Thanks

    Joey

  • #2
    Hello

    when the db connection is borrowed from the datasource(pool)?
    I think you should check the API of the your Pool Provider (C3PO, etc...)

    BTW: what Pool provider you are using?

    Comment

    Working...
    X