tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Daniel Mikusa <dmik...@vmware.com>
Subject Re: JDBC Pool - Error handling during connection creation
Date Thu, 08 Mar 2012 13:07:18 GMT
On Thu, 2012-03-08 at 00:34 -0800, amit shah wrote:
> Comment below
> 
> On Wed, Mar 7, 2012 at 8:53 PM, Christopher Schultz <
> chris@christopherschultz.net> wrote:
> 
> > -----BEGIN PGP SIGNED MESSAGE-----
> > Hash: SHA1
> >
> > Amit,
> >
> > On 3/7/12 12:12 AM, amit shah wrote:
> > > I am using tomcat-jdbc.jar and tomcat-juli.jar from version
> > > 7.0.26.
> > >
> > >> I don't see any place in setupConnection where an exception is
> > >> swallowed, do you?
> > >>
> > >>
> > http://svn.apache.org/viewvc/tomcat/trunk/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/ConnectionPool.java?view=markup
> > >
> > >>
> > > Have a look at the public boolean validate(int
> > > validateAction,String sql) method in PooledConnection class line no
> > > - 445.
> >
> > > The validate method ignores any exception which is thrown while
> > > validating the connection or executing the initSQL query.
> >
> > If you have debug logging enabled, it will log the exception. So,
> > enable debug logging and try again. *shrug*
> >
> > > The createConnection() method in ConnectionPool class which calls
> > > the validate() method returns null in such a case and hence it
> > > leads to a null pointer exception in setupConnection method.
> > >
> > > Ignoring the exception in the validate() method may sound
> > > appropriate (not sure for what reason though) but my point is that
> > > it makes troubleshooting the issue a lot harder.
> >
> > Just turn on debug logging and you'll see the original exception. I
> > think in this case, the error is quite fatal so checking for null and
> > emitting some other error message would only be slightly more helpful
> > to you, but the effect would be the same.
> >
> 
> I understand that turning the log level to debug will display the original
> exception. The point is in production environments the log level would be
> by default info and it would take a longer time to understand the root
> cause.

Why not just set the log level to debug for that particular class?  The
logging in that class seems to be minimal, even at debug level.

> 
> In our case, we execute a SP as an initSQL query, so the reasons why the
> query fails would increase. Hence it would been easier if the validate()
> method throws the exception instead of ignoring it.

I understand that you would like to get access to the exception, but can
you explain why you would want to do this?  What would you do with the
exception?  Where would you handle the exception?

Dan

> 
> Do you see any issues in throwing the exception right there?
> 
> 
> >
> > - -chris
> > -----BEGIN PGP SIGNATURE-----
> > Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
> > Comment: GPGTools - http://gpgtools.org
> > Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
> >
> > iEYEARECAAYFAk9XfYMACgkQ9CaO5/Lv0PBdqQCgjhbGeAQ2QU64XOrYP5VBEkF6
> > VkoAoL6g5gMTaYpnHvj7HZDqWT6P+qcE
> > =AzPZ
> > -----END PGP SIGNATURE-----
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> > For additional commands, e-mail: users-help@tomcat.apache.org
> >
> >
Mime
View raw message