ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Neeraj Kumar Jain <Neerajkumar.J...@Sun.COM>
Subject unsubscribe Re: Connection closing after timeout on tomcat
Date Tue, 05 Sep 2006 05:56:45 GMT
unsubscribe

Poitras Christian wrote:

>Try adding a ping query to your sql-map-config. It will detect closed
>connection and create a new one.
>
>Christian 
>
>-----Original Message-----
>From: Eric Bauld [mailto:baulde@cpsc.ucalgary.ca] 
>Sent: Friday, 25 August 2006 15:19
>To: user-java@ibatis.apache.org
>Subject: Re: Connection closing after timeout on tomcat
>
>Unsure about using DBCP so probably not. I am creating a new instance of
>a SqlMapClient each time a servlet is run.
>
>iBatis 2.1.7
>apache-tomcat 5.5.7
>mysql 4.1.11
>
>The servlets are accessed from a php script and the output is passed
>through apache as a excell file. Its not used that often.
>
>Each servlet executes this
>SQLMapper.setIBATIS( sysprops.getProperty( "ibatis" ) );
>
>And everything that uses ibatis accesses the SqlMapClient does so via
>SQLMapper.getSqlMapInstance()
>
>
>And SQLMapper is as follows
>
>
>package rp.broker;
>
>import java.io.Reader;
>import java.sql.SQLException;
>
>
>import com.ibatis.common.resources.Resources;
>import com.ibatis.sqlmap.client.SqlMapClient;
>import com.ibatis.sqlmap.client.SqlMapClientBuilder;
>
>
>
>public class SQLMapper {
>    private static SqlMapClient sqlMap;
>    private static String iBATIS;
>  
>    private static void setup(){
>        try {
>           
>            String resource = SQLMapper.getIBATIS();
>            Reader reader = Resources.getResourceAsReader(resource);
>            sqlMap = null;
>            SQLMapper.sqlMap =
>SqlMapClientBuilder.buildSqlMapClient(reader);
>        } catch (Exception e) {
>            //An error at this point is unrecoverable, so this should
>die
>            e.printStackTrace();
>            throw new RuntimeException(
>                "Error initializing SQLMapper class.Cause : " +e);
>        }
>    }
>   
>    public static SqlMapClient getSqlMapInstance() throws SQLException {
>
>        return sqlMap;
>    }
>   
>    public static void close(){
>    }
>   
>    public static void setIBATIS(String iBATIS) {
>        SQLMapper.iBATIS = iBATIS;
>        setup();
>    }
>    public static String getIBATIS() {
>        return iBATIS;
>    }
>}
>
>Kris Schneider wrote:
>  
>
>>On 8/25/06, Eric Bauld <baulde@cpsc.ucalgary.ca> wrote:
>>    
>>
>>>Im having a heck of a time finding the right way to fix this.
>>>I have a servlet on a tomcat server, it uses ibatis. It works great 
>>>as long as it is being used but when it sits overnight, the 
>>>connection times out and the next person to use it will get an error.
>>>      
>>>
>
>  
>
>>>But then it will work for every request thereafter.
>>>I get this exception after it has been sitting.
>>>
>>>java.sql.SQLException: No operations allowed after connection closed
>>>
>>>Anyone know of a way to test this to see if the connection has closed
>>>      
>>>
>?
>  
>
>>If you're using DBCP for your connection pooling, see this:
>>
>>http://jakarta.apache.org/commons/dbcp/configuration.html
>>
>>Specifically the testOnBorrow and validationQuery params.
>>
>>    
>>
>>>I could just put a bogus query + error catch to "wake up" the 
>>>connection, but its not a very proper fix.
>>>
>>> - Eric
>>>      
>>>
>
>
>  
>



Mime
View raw message