Return-Path: Delivered-To: apmail-ibatis-user-java-archive@www.apache.org Received: (qmail 75816 invoked from network); 5 Sep 2006 05:57:18 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 5 Sep 2006 05:57:18 -0000 Received: (qmail 11810 invoked by uid 500); 5 Sep 2006 05:57:16 -0000 Delivered-To: apmail-ibatis-user-java-archive@ibatis.apache.org Received: (qmail 11770 invoked by uid 500); 5 Sep 2006 05:57:15 -0000 Mailing-List: contact user-java-help@ibatis.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user-java@ibatis.apache.org Delivered-To: mailing list user-java@ibatis.apache.org Received: (qmail 11759 invoked by uid 99); 5 Sep 2006 05:57:15 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 04 Sep 2006 22:57:15 -0700 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests=UNPARSEABLE_RELAY X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: local policy) Received: from [192.18.98.43] (HELO brmea-mail-2.sun.com) (192.18.98.43) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 04 Sep 2006 22:57:14 -0700 Received: from fe-amer-04.sun.com ([192.18.108.178]) by brmea-mail-2.sun.com (8.13.6+Sun/8.12.9) with ESMTP id k855un4I003914 for ; Mon, 4 Sep 2006 23:56:54 -0600 (MDT) Received: from conversion-daemon.mail-amer.sun.com by mail-amer.sun.com (Sun Java System Messaging Server 6.2-4.02 (built Sep 9 2005)) id <0J5300E01SPIL500@mail-amer.sun.com> (original mail from Neerajkumar.Jain@Sun.COM) for user-java@ibatis.apache.org; Mon, 04 Sep 2006 23:56:49 -0600 (MDT) Received: from [20.142.64.40] ([129.147.76.104]) by mail-amer.sun.com (Sun Java System Messaging Server 6.2-4.02 (built Sep 9 2005)) with ESMTPSA id <0J5300LJ5V6MDU00@mail-amer.sun.com> for user-java@ibatis.apache.org; Mon, 04 Sep 2006 23:56:49 -0600 (MDT) Date: Tue, 05 Sep 2006 11:26:45 +0530 From: Neeraj Kumar Jain Subject: unsubscribe Re: Connection closing after timeout on tomcat In-reply-to: <5820E7E2A928DB46824297946AC2024A9A5F7C@pandore.ircm.priv> Sender: Neerajkumar.Jain@Sun.COM To: user-java@ibatis.apache.org Message-id: <44FD119D.4000601@sun.com> MIME-version: 1.0 Content-type: text/plain; format=flowed; charset=ISO-8859-1 Content-transfer-encoding: 7BIT X-Accept-Language: en-us, en References: <5820E7E2A928DB46824297946AC2024A9A5F7C@pandore.ircm.priv> User-Agent: Mozilla Thunderbird 1.0.2 (X11/20050322) X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N 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 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 >>> >>> > > > >