tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Craig R. McClanahan" <>
Subject Re: possible JDBCRealm bug?
Date Thu, 01 Aug 2002 21:15:44 GMT

On Thu, 1 Aug 2002 wrote:

> Date: Thu, 1 Aug 2002 17:09:11 -0400
> From:
> Reply-To: Tomcat Developers List <>
> To:
> Subject: possible JDBCRealm bug?
> opens a database connection and never
> closes the connection.
> Would not a more correct behaviour be to open/close the connection
> before/after verifying credentials?

Doing this would make authentication horrendously slow on many databases,
where establishing a connection can take many seconds.  A better approach
would be to use a connection pool (because you could then support multiple
simultaneous authenications) -- but that doesn't solve your "open
connections" issue.

> When the connection is kept open, the corresponding database is held up.
> For example, when using postgres, one cannot shutdown and restart the db
> server without first
> shutting down tomcat.
> thought? opinions?

IMHO this is going to be the case for any web application that uses a
connection pool anyway.  However, one thing that many connection pools let
you do is define a "validation query" or "ping query" that must succeed
before the connection is returned to the user -- this would cause all the
bad connections in the pool to get thrown away without impacting the app
(other than the longer than usual time to establish a new replacement

Modifying JDBCRealm to use such a connection pool would seem like the best
course of action.

> -Tony Chao


To unsubscribe, e-mail:   <>
For additional commands, e-mail: <>

View raw message