pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
PostgreSQL/Tomcat JNDI Datasource Questions
6+ messages / 3 participants
[nested] [flat]

* PostgreSQL/Tomcat JNDI Datasource Questions
@ 2005-05-11 22:53 Warren Killian <warrenk19@comcast.net>
  2005-05-11 23:05 ` Re: PostgreSQL/Tomcat JNDI Datasource Questions Dave Cramer <pg@fastcrypt.com>
  2005-05-13 00:57 ` Re: PostgreSQL/Tomcat JNDI Datasource Questions David Gagnon <dgagnon@siunik.com>
  2005-05-13 01:00 ` Re: PostgreSQL/Tomcat JNDI Datasource Questions David Gagnon <dgagnon@siunik.com>
  0 siblings, 3 replies; 6+ messages in thread

From: Warren Killian @ 2005-05-11 22:53 UTC (permalink / raw)
  To: pgsql-jdbc

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:

        <Context className="org.apache.catalina.core.StandardContext"
                 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">

          <Resource name="jdbc/test" scope="Shareable"
                           type="javax.sql.DataSource"/>
          <ResourceParams name="jdbc/test">
            <parameter>
               <name>factory</name>
               <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
            </parameter>
            <parameter>
              <name>driverClassName</name>
              <value>org.postgresql.Driver</value>
            </parameter>
            <parameter>
              <name>url</name>
              <value>jdbc:postgresql://myIP/test</value>
            </parameter>
            <parameter>
              <name>username</name>
              <value>Whoopie</value>
            </parameter>
            <parameter>
              <name>password</name>
              <value>Doopie</value>
            </parameter>
            <parameter>
               <name>removeAbandoned</name>
               <value>true</value>
            </parameter>
            <parameter>
               <name>removeAbandonedTimeout</name>
               <value>20</value>
            </parameter>
            <parameter>
              <name>maxWait</name>
              <value>5000</value>
            </parameter>
            <parameter>
              <name>maxActive</name>
              <value>5</value>
            </parameter>
            <parameter>
              <name>maxIdle</name>
              <value>2</value>
            </parameter>
            <parameter>
              <name>validationQuery</name>
              <value>SELECT * FROM test</value>
            </parameter>
          </ResourceParams>
        </Context>

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.

-- 
Thank you,
Warren Killian
warrenk19@comcast.net

Q: How many Zen masters does it take to screw in a light bulb?
A: None. The universe spins the bulb and the Zen master stays out
   of the way.




^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: PostgreSQL/Tomcat JNDI Datasource Questions
  2005-05-11 22:53 PostgreSQL/Tomcat JNDI Datasource Questions Warren Killian <warrenk19@comcast.net>
@ 2005-05-11 23:05 ` Dave Cramer <pg@fastcrypt.com>
  2005-05-12 00:15   ` Re: PostgreSQL/Tomcat JNDI Datasource Questions Warren Killian <warrenk19@comcast.net>
  2 siblings, 1 reply; 6+ messages in thread

From: Dave Cramer @ 2005-05-11 23:05 UTC (permalink / raw)
  To: Warren Killian <warrenk19@comcast.net>; +Cc: pgsql-jdbc

Warren,

You need to implement destroy in your servlet and close the connections 
when the servlet is destroyed.

Dave

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:
>
>        <Context className="org.apache.catalina.core.StandardContext"
>                 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">
>
>          <Resource name="jdbc/test" scope="Shareable"
>                           type="javax.sql.DataSource"/>
>          <ResourceParams name="jdbc/test">
>            <parameter>
>               <name>factory</name>
>               
> <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
>            </parameter>
>            <parameter>
>              <name>driverClassName</name>
>              <value>org.postgresql.Driver</value>
>            </parameter>
>            <parameter>
>              <name>url</name>
>              <value>jdbc:postgresql://myIP/test</value>
>            </parameter>
>            <parameter>
>              <name>username</name>
>              <value>Whoopie</value>
>            </parameter>
>            <parameter>
>              <name>password</name>
>              <value>Doopie</value>
>            </parameter>
>            <parameter>
>               <name>removeAbandoned</name>
>               <value>true</value>
>            </parameter>
>            <parameter>
>               <name>removeAbandonedTimeout</name>
>               <value>20</value>
>            </parameter>
>            <parameter>
>              <name>maxWait</name>
>              <value>5000</value>
>            </parameter>
>            <parameter>
>              <name>maxActive</name>
>              <value>5</value>
>            </parameter>
>            <parameter>
>              <name>maxIdle</name>
>              <value>2</value>
>            </parameter>
>            <parameter>
>              <name>validationQuery</name>
>              <value>SELECT * FROM test</value>
>            </parameter>
>          </ResourceParams>
>        </Context>
>
> 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.
>

-- 
Dave Cramer
http://www.postgresintl.com
519 939 0336
ICQ#14675561




^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: PostgreSQL/Tomcat JNDI Datasource Questions
  2005-05-11 22:53 PostgreSQL/Tomcat JNDI Datasource Questions Warren Killian <warrenk19@comcast.net>
  2005-05-11 23:05 ` Re: PostgreSQL/Tomcat JNDI Datasource Questions Dave Cramer <pg@fastcrypt.com>
@ 2005-05-12 00:15   ` Warren Killian <warrenk19@comcast.net>
  2005-05-12 00:46     ` Re: PostgreSQL/Tomcat JNDI Datasource Questions Dave Cramer <pg@fastcrypt.com>
  0 siblings, 1 reply; 6+ messages in thread

From: Warren Killian @ 2005-05-12 00:15 UTC (permalink / raw)
  To: pgsql-jdbc

Hi Dave,

Good advice.  But I'm afraid not using Servlets.  My application is 
written entirely with JSP's in which I'm using the JSTL actions to 
perform all of the database operations.  I've scanned all the 
information I can find on the "sql" JSTL and haven't found any action 
which would let me specifically close database connections.  Have I 
missed something in my research?  Thanks for the feedback.

Warren Killian
warrenk19@comcast.net

Dave Cramer wrote:

> Warren,
>
> You need to implement destroy in your servlet and close the 
> connections when the servlet is destroyed.
>
> Dave
>
> 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:
>>
>>        <Context className="org.apache.catalina.core.StandardContext"
>>                 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">
>>
>>          <Resource name="jdbc/test" scope="Shareable"
>>                           type="javax.sql.DataSource"/>
>>          <ResourceParams name="jdbc/test">
>>            <parameter>
>>               <name>factory</name>
>>               
>> <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
>>            </parameter>
>>            <parameter>
>>              <name>driverClassName</name>
>>              <value>org.postgresql.Driver</value>
>>            </parameter>
>>            <parameter>
>>              <name>url</name>
>>              <value>jdbc:postgresql://myIP/test</value>
>>            </parameter>
>>            <parameter>
>>              <name>username</name>
>>              <value>Whoopie</value>
>>            </parameter>
>>            <parameter>
>>              <name>password</name>
>>              <value>Doopie</value>
>>            </parameter>
>>            <parameter>
>>               <name>removeAbandoned</name>
>>               <value>true</value>
>>            </parameter>
>>            <parameter>
>>               <name>removeAbandonedTimeout</name>
>>               <value>20</value>
>>            </parameter>
>>            <parameter>
>>              <name>maxWait</name>
>>              <value>5000</value>
>>            </parameter>
>>            <parameter>
>>              <name>maxActive</name>
>>              <value>5</value>
>>            </parameter>
>>            <parameter>
>>              <name>maxIdle</name>
>>              <value>2</value>
>>            </parameter>
>>            <parameter>
>>              <name>validationQuery</name>
>>              <value>SELECT * FROM test</value>
>>            </parameter>
>>          </ResourceParams>
>>        </Context>
>>
>> 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.
>>
>

-- 
Thank you,
Warren Killian
warrenk19@comcast.net

Q: How many Zen masters does it take to screw in a light bulb?
A: None. The universe spins the bulb and the Zen master stays out
   of the way.




^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: PostgreSQL/Tomcat JNDI Datasource Questions
  2005-05-11 22:53 PostgreSQL/Tomcat JNDI Datasource Questions Warren Killian <warrenk19@comcast.net>
  2005-05-11 23:05 ` Re: PostgreSQL/Tomcat JNDI Datasource Questions Dave Cramer <pg@fastcrypt.com>
  2005-05-12 00:15   ` Re: PostgreSQL/Tomcat JNDI Datasource Questions Warren Killian <warrenk19@comcast.net>
@ 2005-05-12 00:46     ` Dave Cramer <pg@fastcrypt.com>
  0 siblings, 0 replies; 6+ messages in thread

From: Dave Cramer @ 2005-05-12 00:46 UTC (permalink / raw)
  To: Warren Killian <warrenk19@comcast.net>; +Cc: pgsql-jdbc

Warren,

A JSP ends up being a servlet at some point. So I'd say that there 
should still be a way to implement destroy inside a jsp page. ( I don't 
believe in JSP, and this is just another reason )

Just thinking out loud you should be able to put a servlet into your 
webapp that will just close the pool.  All it would do is start on load, 
and run destroy

Dave

Warren Killian wrote:

> Hi Dave,
>
> Good advice.  But I'm afraid not using Servlets.  My application is 
> written entirely with JSP's in which I'm using the JSTL actions to 
> perform all of the database operations.  I've scanned all the 
> information I can find on the "sql" JSTL and haven't found any action 
> which would let me specifically close database connections.  Have I 
> missed something in my research?  Thanks for the feedback.
>
> Warren Killian
> warrenk19@comcast.net
>
> Dave Cramer wrote:
>
>> Warren,
>>
>> You need to implement destroy in your servlet and close the 
>> connections when the servlet is destroyed.
>>
>> Dave
>>
>> 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:
>>>
>>>        <Context className="org.apache.catalina.core.StandardContext"
>>>                 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">
>>>
>>>          <Resource name="jdbc/test" scope="Shareable"
>>>                           type="javax.sql.DataSource"/>
>>>          <ResourceParams name="jdbc/test">
>>>            <parameter>
>>>               <name>factory</name>
>>>               
>>> <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
>>>            </parameter>
>>>            <parameter>
>>>              <name>driverClassName</name>
>>>              <value>org.postgresql.Driver</value>
>>>            </parameter>
>>>            <parameter>
>>>              <name>url</name>
>>>              <value>jdbc:postgresql://myIP/test</value>
>>>            </parameter>
>>>            <parameter>
>>>              <name>username</name>
>>>              <value>Whoopie</value>
>>>            </parameter>
>>>            <parameter>
>>>              <name>password</name>
>>>              <value>Doopie</value>
>>>            </parameter>
>>>            <parameter>
>>>               <name>removeAbandoned</name>
>>>               <value>true</value>
>>>            </parameter>
>>>            <parameter>
>>>               <name>removeAbandonedTimeout</name>
>>>               <value>20</value>
>>>            </parameter>
>>>            <parameter>
>>>              <name>maxWait</name>
>>>              <value>5000</value>
>>>            </parameter>
>>>            <parameter>
>>>              <name>maxActive</name>
>>>              <value>5</value>
>>>            </parameter>
>>>            <parameter>
>>>              <name>maxIdle</name>
>>>              <value>2</value>
>>>            </parameter>
>>>            <parameter>
>>>              <name>validationQuery</name>
>>>              <value>SELECT * FROM test</value>
>>>            </parameter>
>>>          </ResourceParams>
>>>        </Context>
>>>
>>> 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.
>>>
>>
>

-- 
Dave Cramer
http://www.postgresintl.com
519 939 0336
ICQ#14675561




^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: PostgreSQL/Tomcat JNDI Datasource Questions
  2005-05-11 22:53 PostgreSQL/Tomcat JNDI Datasource Questions Warren Killian <warrenk19@comcast.net>
@ 2005-05-13 00:57 ` David Gagnon <dgagnon@siunik.com>
  2 siblings, 0 replies; 6+ messages in thread

From: David Gagnon @ 2005-05-13 00:57 UTC (permalink / raw)
  To: Warren Killian <warrenk19@comcast.net>; +Cc: pgsql-jdbc

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:
>
>        <Context className="org.apache.catalina.core.StandardContext"
>                 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">
>
>          <Resource name="jdbc/test" scope="Shareable"
>                           type="javax.sql.DataSource"/>
>          <ResourceParams name="jdbc/test">
>            <parameter>
>               <name>factory</name>
>               
> <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
>            </parameter>
>            <parameter>
>              <name>driverClassName</name>
>              <value>org.postgresql.Driver</value>
>            </parameter>
>            <parameter>
>              <name>url</name>
>              <value>jdbc:postgresql://myIP/test</value>
>            </parameter>
>            <parameter>
>              <name>username</name>
>              <value>Whoopie</value>
>            </parameter>
>            <parameter>
>              <name>password</name>
>              <value>Doopie</value>
>            </parameter>
>            <parameter>
>               <name>removeAbandoned</name>
>               <value>true</value>
>            </parameter>
>            <parameter>
>               <name>removeAbandonedTimeout</name>
>               <value>20</value>
>            </parameter>
>            <parameter>
>              <name>maxWait</name>
>              <value>5000</value>
>            </parameter>
>            <parameter>
>              <name>maxActive</name>
>              <value>5</value>
>            </parameter>
>            <parameter>
>              <name>maxIdle</name>
>              <value>2</value>
>            </parameter>
>            <parameter>
>              <name>validationQuery</name>
>              <value>SELECT * FROM test</value>
>            </parameter>
>          </ResourceParams>
>        </Context>
>
> 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.
>




^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: PostgreSQL/Tomcat JNDI Datasource Questions
  2005-05-11 22:53 PostgreSQL/Tomcat JNDI Datasource Questions Warren Killian <warrenk19@comcast.net>
@ 2005-05-13 01:00 ` David Gagnon <dgagnon@siunik.com>
  2 siblings, 0 replies; 6+ messages in thread

From: David Gagnon @ 2005-05-13 01:00 UTC (permalink / raw)
  To: Warren Killian <warrenk19@comcast.net>; +Cc: pgsql-jdbc

This is my config and works well.  Look 
http://jakarta.apache.org/tomcat/tomcat-4.1-doc/jndi-datasource-examples-howto.html 
for details.


/David
    <Resource name="jdbc/webCatalog" auth="Container"
        type="javax.sql.DataSource"/>

    <ResourceParams name="jdbc/webCatalog">
        <parameter>
            <name>factory</name>
            <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
        </parameter>
        <parameter>
            <name>driverClassName</name>
            <value>org.postgresql.Driver</value>
        </parameter>
        <parameter>
            <name>url</name>
            <value>jdbc:postgresql://toto.tata.com:5432/webCatalog</value>
        </parameter>
        <parameter>
            <name>username</name>  <!--Dont forget to change the realm 
username/password to-->
            <value>ecologic</value>
        </parameter>
        <parameter>
            <name>password</name>
            <value>eco10_</value>
        </parameter>
        <parameter>
            <name>maxActive</name>
            <value>25</value>
        </parameter>
        <!-- Maximum number of idle dB connections to retain in pool.
        Set to 0 for no limit.
        -->
        <parameter>
            <name>maxIdle</name>
            <value>0</value>
        </parameter>
        <!-- Maximum time to wait for a dB connection to become available
        in ms, in this example 10 seconds.  An Exception is thrown if
        this timeout is exceeded.  Set to -1 to wait indefinitely.
        -->
        <parameter>
            <name>maxWait</name>
            <value>-1</value>
        </parameter>
        <!-- To configure a DBCP DataSource so that abandoned dB 
connections are removed and
        recycled add the following paramater to the ResourceParams 
configuration for your DBCP
        DataSource Resource: -->
        <parameter>
            <name>removeAbandoned</name>
            <value>true</value>
        </parameter>
        <!--Use the removeAbandonedTimeout parameter to set the number of
        seconds a dB connection has been idle before it is considered 
abandoned. -->
        <parameter>
            <name>removeAbandonedTimeout</name>
            <value>12600</value>   <!--Wait 3 hour before statuating a 
connection is abandoned-->
        </parameter>

        <!-- The logAbandoned parameter can be set to true if you want 
DBCP to log a stack trace
        of the code which abandoned the dB connection resources. -->

        <parameter>
            <name>logAbandoned</name>
            <value>true</value>
        </parameter>


    </ResourceParams>


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:
>
>        <Context className="org.apache.catalina.core.StandardContext"
>                 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">
>
>          <Resource name="jdbc/test" scope="Shareable"
>                           type="javax.sql.DataSource"/>
>          <ResourceParams name="jdbc/test">
>            <parameter>
>               <name>factory</name>
>               
> <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
>            </parameter>
>            <parameter>
>              <name>driverClassName</name>
>              <value>org.postgresql.Driver</value>
>            </parameter>
>            <parameter>
>              <name>url</name>
>              <value>jdbc:postgresql://myIP/test</value>
>            </parameter>
>            <parameter>
>              <name>username</name>
>              <value>Whoopie</value>
>            </parameter>
>            <parameter>
>              <name>password</name>
>              <value>Doopie</value>
>            </parameter>
>            <parameter>
>               <name>removeAbandoned</name>
>               <value>true</value>
>            </parameter>
>            <parameter>
>               <name>removeAbandonedTimeout</name>
>               <value>20</value>
>            </parameter>
>            <parameter>
>              <name>maxWait</name>
>              <value>5000</value>
>            </parameter>
>            <parameter>
>              <name>maxActive</name>
>              <value>5</value>
>            </parameter>
>            <parameter>
>              <name>maxIdle</name>
>              <value>2</value>
>            </parameter>
>            <parameter>
>              <name>validationQuery</name>
>              <value>SELECT * FROM test</value>
>            </parameter>
>          </ResourceParams>
>        </Context>
>
> 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.
>




^ permalink  raw  reply  [nested|flat] 6+ messages in thread


end of thread, other threads:[~2005-05-13 01:00 UTC | newest]

Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2005-05-11 22:53 PostgreSQL/Tomcat JNDI Datasource Questions Warren Killian <warrenk19@comcast.net>
2005-05-11 23:05 ` Dave Cramer <pg@fastcrypt.com>
2005-05-12 00:15   ` Warren Killian <warrenk19@comcast.net>
2005-05-12 00:46     ` Dave Cramer <pg@fastcrypt.com>
2005-05-13 00:57 ` David Gagnon <dgagnon@siunik.com>
2005-05-13 01:00 ` David Gagnon <dgagnon@siunik.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox