tomcat-taglibs-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Hans Bergsten <h...@gefionsoftware.com>
Subject Re: How to close a database connection with JSTL?
Date Mon, 11 Nov 2002 19:16:56 GMT
Johann Uhrmann wrote:
> Am Montag, 11. November 2002 18:40 schrieb Hans Bergsten:
> 
>>Johann Uhrmann wrote:
>> > Hi,
>> >
>> > are database connections automatically closed by the jstl on pages
>> > which use the <sql:setDataSource ...> tag?
>> >
>> > I use this tag to connect to a database connection pool and the pool
>> > is running out of available connections from time to time.
>>
>>The <sql:setDataSource> action creates a DataSource _without_ pooling,
>>in the most common case (you can use it to expose a pooled DataSource,
>>created by some other code, but that's rarely how it's used).
>>
>>The <sql:query>, <sql:update> and <sql:transaction> actions always
>>close the Connection they get from the DataSource.
> 
> 
> Thank You, as far as I know, that behaviour is not documented in the 
> jstl-documentations.

It is. Look at the JSTL specification. The descriptions for these
SQL actions includes a description of how a Connection is obtained
and released.

>>So if you're using <sql:setDataSource> in the typical way, plus the
>>other JSTL SQL actions, I doubt that the problem lies with JSTL. You
>>may want to elaborate on "I use this tag to connect to a database
>>connection pool" and also tell us if you use the pool from some other
>>code than the JSTL SQL actions.
> 
> 
> I am using the setDataSource tag in order to get the database connection
> pool which is provided by tomcat:
> <sql:setDataSource var="mydb" dataSource="jdbc/foodb" />

Okay. This is rendundant, though. You can as well use the JNDI name
directly in the dataSource attribute for the query and update actions:

   <sql:query dataSource="jdbc/foodb" ... />

> However, there might be a different source for my problem as not just the
> connection pool told me that it's out of connection but also the database 
> engine itself.

Hans
-- 
Hans Bergsten		hans@gefionsoftware.com
Gefion Software		http://www.gefionsoftware.com
JavaServer Pages	http://TheJSPBook.com


--
To unsubscribe, e-mail:   <mailto:taglibs-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:taglibs-user-help@jakarta.apache.org>


Mime
View raw message