Return-Path: Delivered-To: apmail-ibatis-user-java-archive@www.apache.org Received: (qmail 43415 invoked from network); 27 May 2008 15:09:29 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 27 May 2008 15:09:29 -0000 Received: (qmail 17040 invoked by uid 500); 27 May 2008 15:09:23 -0000 Delivered-To: apmail-ibatis-user-java-archive@ibatis.apache.org Received: (qmail 17003 invoked by uid 500); 27 May 2008 15:09:23 -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 16958 invoked by uid 99); 27 May 2008 15:09:23 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 27 May 2008 08:09:22 -0700 X-ASF-Spam-Status: No, hits=2.0 required=10.0 tests=HTML_MESSAGE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of fdmanana@gmail.com designates 64.233.170.187 as permitted sender) Received: from [64.233.170.187] (HELO rn-out-0910.google.com) (64.233.170.187) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 27 May 2008 15:08:34 +0000 Received: by rn-out-0910.google.com with SMTP id j66so1473626rne.9 for ; Tue, 27 May 2008 08:08:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:reply-to:sender:to:subject:in-reply-to:mime-version:content-type:references:x-google-sender-auth; bh=mzxl16yQ9ETDpL0ImChctNx+2RodWrUNwBJ5k/OD2LM=; b=W4EOslf/bN5O0plRk3fBlFp0IiY06m6vTUpPC3nJvPQ8rBMAp7zs2TdKY0ekLmb/3TvBKg06+laMQnzxg/OoLf9JI6rrf1KvrMyfjW0SiUsP2flnSJeblaII9zLEmbqp3b/AQQJfyuwUSMh+Qh9Z5uSoHnfLBf6Nv6ly+qQQ5jg= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:reply-to:sender:to:subject:in-reply-to:mime-version:content-type:references:x-google-sender-auth; b=r4Ek3p22jMQPDkj0YwNifDHx7Pnju8Oaqjem1qWvggcSu8m1DAK2dpMJhBXm6ME723FEgr9Fe6Mu53+hwjKOytqcYdxwiMCkLstzVDHLfErayYe9y6hM9vqyXVcZWg1+cKQAAurjPH1xYdKpdIWni8Lidi1eb80uTsZNAp5kvl0= Received: by 10.114.184.11 with SMTP id h11mr1402440waf.175.1211900928079; Tue, 27 May 2008 08:08:48 -0700 (PDT) Received: by 10.115.111.15 with HTTP; Tue, 27 May 2008 08:08:48 -0700 (PDT) Message-ID: Date: Tue, 27 May 2008 17:08:48 +0200 From: "Filipe David Manana" Reply-To: fdmanana@ieee.org Sender: fdmanana@gmail.com To: user-java@ibatis.apache.org Subject: Re: iBATIS querying pattern for web applications In-Reply-To: <536e8800805270728q78dc297u211aa4a6b05bdada@mail.gmail.com> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_20359_12633288.1211900928066" References: <536e8800805270728q78dc297u211aa4a6b05bdada@mail.gmail.com> X-Google-Sender-Auth: 138c92148e312fbc X-Virus-Checked: Checked by ClamAV on apache.org ------=_Part_20359_12633288.1211900928066 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-Disposition: inline Not really. I was catching exceptions, just omitted them in the email for the sake of shortness :). So, the possibility of leaving sessions open is strange, as there are no more than 1 request at a time, as the queries are very simple and with small result sets, so the life period of sessions should be very short, less than a few seconds maybe. On Tue, May 27, 2008 at 4:28 PM, Nicholoz Koka Kiknadze wrote: > Can your query raise exception that's handled elsewhere, so that > session.close() is not called? Try this: > > > SqlMapSession session = sqlMap.openSession(); > List list = null; > try { > list = (List) session.queryForList("queryId"); > } > catch (Exception e) > { > log..... > } > finally { > session.close(); > } > > > On Tue, May 27, 2008 at 6:09 PM, Filipe David Manana > wrote: > >> Hello, >> >> I am developing a webapp and using iBATIS for the first time. I configured >> iBATIS to use a JDBC transaction manager and a JNDI datasource, provided by >> Tomcat+DBCP. When my webapp is deployed, a Servlet executes and initializes >> iBATIS : >> >> SqlMapClient sqlMap = null; >> Reader reader = null; >> >> try >> { >> reader = Resources.getResourceAsReader(configFile); >> } >> catch( Exception ex ) >> { >> String error = "Could not get Reader for iBATIS config file: " + >> ex; >> log.fatal(error); >> >> throw new DatabaseException(error); >> } >> >> try >> { >> sqlMap = SqlMapClientBuilder.buildSqlMapClient(reader); >> } >> catch( Exception ex ) >> { >> String error = "Could not create iBATIS SqlMapClient object: " + >> ex; >> log.fatal(error); >> >> throw new DatabaseException(error); >> } >> >> >> This initialization is done only once. For each http request, I use the >> sqlMap object to get a new session, execute select queries (through >> queryForList method) and close the session. The pattern is like this: >> >> SqlMapSession session = sqlMap.openSession(); >> List list = null; >> >> list = (List) session.queryForList("queryId"); >> session.close(); >> >> Although I frequently get the SQLException : >> >> java.sql.SQLException: ORA-02391: exceeded simultaneous >> SESSIONS_PER_USER limit >> >> Am I doing something wrong? I am the only user. My Tomcat+DBCP >> configuration is supposedly ok, as it is the same I used for another >> application (using Hibernate and same Database Server). It seems to me that >> iBATIS is somehow not releasing the DB connections. >> I am using iBATIS 2.3.0 >> >> cheers >> >> -- >> Filipe David Manana, >> fdmanana@ieee.org >> >> "First they ignore you, then they laugh at you, then they fight you, then >> you win." >> > > -- Filipe David Manana, fdmanana@ieee.org "First they ignore you, then they laugh at you, then they fight you, then you win." ------=_Part_20359_12633288.1211900928066 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-Disposition: inline Not really. I was catching exceptions, just omitted them in the email for the sake of shortness :).
So, the possibility of leaving sessions open is strange, as there are no more than 1 request at a time, as the queries are very simple and with small result sets, so the life period of sessions should be very short, less than a few seconds maybe.

On Tue, May 27, 2008 at 4:28 PM, Nicholoz Koka Kiknadze <kiknadze@gmail.com> wrote:
Can your query raise exception that's handled elsewhere, so that session.close() is not called? Try this:



      SqlMapSession session = sqlMap.openSession();    
      List list = null;
      try {

      list = (List) session.queryForList("queryId");    
        }
       catch (Exception e)
       {
            log.....
        }
       finally {
              session.close();
       }


On Tue, May 27, 2008 at 6:09 PM, Filipe David Manana <fdmanana@ieee.org> wrote:
Hello,

I am developing a webapp and using iBATIS for the first time. I configured iBATIS to use a JDBC transaction manager and a JNDI datasource, provided by Tomcat+DBCP. When my webapp is deployed, a Servlet executes and initializes iBATIS :

      SqlMapClient sqlMap = null;
      Reader reader = null;

      try
      {
         reader = Resources.getResourceAsReader(configFile);
      }
      catch( Exception ex )
      {
         String error = "Could not get Reader for iBATIS config file: " + ex;
         log.fatal(error);

         throw new DatabaseException(error);
      }

      try
      {
         sqlMap = SqlMapClientBuilder.buildSqlMapClient(reader);
      }
      catch( Exception ex )
      {
         String error = "Could not create iBATIS SqlMapClient object: " + ex;
         log.fatal(error);

         throw new DatabaseException(error);
      }


This initialization is done only once. For each http request, I use the sqlMap object to get a new session, execute select queries (through queryForList method) and close the session. The pattern is like this:

      SqlMapSession session = sqlMap.openSession();    
      List list = null;
     
      list = (List) session.queryForList("queryId");    
      session.close();

Although I frequently get the SQLException :

    java.sql.SQLException: ORA-02391: exceeded simultaneous SESSIONS_PER_USER limit

Am I doing something wrong? I am the only user. My Tomcat+DBCP configuration is supposedly ok, as it is the same I used for another application (using Hibernate and same Database Server). It seems to me that iBATIS is somehow not releasing the DB connections.
I am using iBATIS 2.3.0

cheers

--
Filipe David Manana,
fdmanana@ieee.org

"First they ignore you, then they laugh at you, then they fight you, then you win."




--
Filipe David Manana,
fdmanana@ieee.org

"First they ignore you, then they laugh at you, then they fight you, then you win."
------=_Part_20359_12633288.1211900928066--