tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Edoardo Panfili <edoa...@aspix.it>
Subject Re: How to close open connections after application stop?
Date Sun, 22 Feb 2009 15:10:29 GMT
Mark Thomas ha scritto:
> Edoardo Panfili wrote:
>> Hy,
>>
>> I have one webapp in Tomcat 6.0.18 with this context:
>>
>> <Context path="/myApp" docBase="myApp" debug="100" reloadable="true">
>>   <Resource name="jdbc/myApp" auth="Container"
>>       type="javax.sql.DataSource"
>>       maxActive="8" maxIdle="5" maxWait="300"
>>       username="myApp" password="passwd"
>>       driverClassName="org.postgresql.Driver"
>>       url="jdbc:postgresql://127.0.0.1:5432/myApp"
>>       removeAbandoned="true"
>>       removeAbandonedTimeout="30"
>>       logAbandoned="true"
>>   />
>> </Context>
>>
>> After application stop (using tomcat manager) I'd like to (drastic
>> example) rename the db, but I can't do it because there are open
>> connections.
>>
>> There are no other application using myApp db, but with "ps ax" I can see:
>>
>> 189   ??  Ss     0:02.67 postgres: myApp myApp 127.0.0.1(49162) idle
>>
>> Is there a way to close the connection without closing Toncat?
> 
> Hmm. If you were managing your own pool then you could call close() on
> the pool.
> 
> Arguably, if Tomcat creates an context level pool, Tomcat should close
> it when the context stops but I don't think it does. That probably calls
> for some testing to check behaviour and possibly an enhancement request.
this is my code to retrieve a connection
-----------------------
ambiente = (Context) new InitialContext().lookup("java:comp/env");
pool = (DataSource) ambiente.lookup("jdbc/anArchive");
Connection conn = pool.getConnection();
......
conn.close(); // this in inside finally
-----------------------

but If my code is wrong removeAbandoned="true" is a guaranty to have the 
connection closed after few time (30sec). is this right?


> Can you close the connections from the database management tools?
I'm sorry but: where can I found it? (Do you mean from postgres? can't 
figure how)

I am searching for that also inside tomcatProbe but can't find it.


thank you
Edoardo


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message