X-Original-To: pgsql-jdbc-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 4E490533A6 for ; Thu, 12 May 2005 21:52:42 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 26934-10 for ; Fri, 13 May 2005 00:52:32 +0000 (GMT) Received: from relais.videotron.ca (relais.videotron.ca [24.201.245.36]) by svr1.postgresql.org (Postfix) with ESMTP id 6B4685294C for ; Thu, 12 May 2005 21:52:31 -0300 (ADT) Received: from [192.168.1.101] ([24.202.23.128]) by VL-MO-MR010.ip.videotron.ca (iPlanet Messaging Server 5.2 HotFix 1.21 (built Sep 8 2003)) with ESMTP id <0IGE006HFL3MN4@VL-MO-MR010.ip.videotron.ca> for pgsql-jdbc@postgresql.org; Thu, 12 May 2005 20:52:34 -0400 (EDT) Date: Thu, 12 May 2005 20:57:03 -0400 From: David Gagnon Subject: Re: PostgreSQL/Tomcat JNDI Datasource Questions In-reply-to: <42828CF9.5070008@comcast.net> To: Warren Killian Cc: pgsql-jdbc@postgresql.org Message-id: <4283FB5F.3000001@siunik.com> MIME-version: 1.0 Content-type: text/plain; charset=ISO-8859-1; format=flowed Content-transfer-encoding: 7BIT X-Accept-Language: en-us, en User-Agent: Mozilla Thunderbird 1.0.2 (Windows/20050317) References: <42828CF9.5070008@comcast.net> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.02 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/70 X-Sequence-Number: 12901 Hi, You are using DBCP wich is a connection pool. The purpose of this framework is to avoid closing connection right (for performance matters)? /David Warren Killian wrote: > Hello group, > > I have several questions concerning configuring and using a JNDI > DataSource > with PostgreSQL and Apache Tomcat. Currently I have > successfully configured a "basic" DataSource. Currently, my > configuration > which resides in a context.xml file is as follows: > > backgroundProcessorDelay="-1" > cachingAllowed="true" > > charsetMapperClass="org.apache.catalina.util.CharsetMapper" > > configFile="/usr/local/jwsdp-1.3/conf/Catalina/localhost/test.xml" > cookies="true" > crossContext="false" > debug="0" > displayName="test" > docBase="/usr/local/jwsdp-1.3/webapps/test" > domain="Catalina" > engineName="Catalina" > j2EEApplication="none" > j2EEServer="none" > lazy="true" > managerChecksFrequency="6" > path="/test" > privileged="false" > reloadable="true" > startupTime="8" > swallowOutput="false" > tldScanTime="0" > useNaming="true" > wrapperClass="org.apache.catalina.core.StandardWrapper"> > > type="javax.sql.DataSource"/> > > > factory > > org.apache.commons.dbcp.BasicDataSourceFactory > > > driverClassName > org.postgresql.Driver > > > url > jdbc:postgresql://myIP/test > > > username > Whoopie > > > password > Doopie > > > removeAbandoned > true > > > removeAbandonedTimeout > 20 > > > maxWait > 5000 > > > maxActive > 5 > > > maxIdle > 2 > > > validationQuery > SELECT * FROM test > > > > > Using the above configuration, my JSP pages can connect to PostgreSQL and > perform all required database operations. > > But all is not right! I have the following issues: > > 1.) Connections are NEVER closed > Say I hit my JSP page which perform a query and display the results. > Using netstat I can see that one connection to PostgreSQL has been > established. But then, if I uninstall and reinstall my web app and > hit my > JSP page again, then the output of "netstat -p -t" shows that a second > connection to PostgreSQL is established. The first connection never > goes away! If I continue to > uninstall/reinstall/hit JSP page, the connections continue to acrue and > never go away. The number of connections can even exceed the value of > "maxActive" defined in my context.xml file. What am I doing wrong? > > 2.) Idle connections aren't closed > As mentioned above, the connections which are opened by my web app are > kept around forever and never closed. In my context.xml file above, I've > defined the "removeAbandoned" parameter to true and have set the > "removeAbandonedTimeout" parameter to 20 seconds. But the connections > are > never closed. Every time I run "netstat -p -t", the connections are > still there. :( > > 3.) Is my configuration correct for performing Pooling? > I "can" get "a" database connection using this configuration. But is > this > adequate to perform connection pooling? How can I tell if/when > connection > pooling is actually being performed correctly? > Any help would be greatly appreciated. >