Return-Path: Delivered-To: apmail-tomcat-users-archive@www.apache.org Received: (qmail 14791 invoked from network); 7 Dec 2008 14:36:31 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 7 Dec 2008 14:36:31 -0000 Received: (qmail 10533 invoked by uid 500); 7 Dec 2008 14:36:32 -0000 Delivered-To: apmail-tomcat-users-archive@tomcat.apache.org Received: (qmail 10513 invoked by uid 500); 7 Dec 2008 14:36:32 -0000 Mailing-List: contact users-help@tomcat.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Tomcat Users List" Delivered-To: mailing list users@tomcat.apache.org Received: (qmail 10502 invoked by uid 99); 7 Dec 2008 14:36:32 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 07 Dec 2008 06:36:32 -0800 X-ASF-Spam-Status: No, hits=1.2 required=10.0 tests=SPF_NEUTRAL X-Spam-Check-By: apache.org Received-SPF: neutral (athena.apache.org: local policy) Received: from [76.96.30.17] (HELO QMTA10.emeryville.ca.mail.comcast.net) (76.96.30.17) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 07 Dec 2008 14:35:00 +0000 Received: from OMTA04.emeryville.ca.mail.comcast.net ([76.96.30.35]) by QMTA10.emeryville.ca.mail.comcast.net with comcast id oEYc1a0050lTkoCAAEbdLd; Sun, 07 Dec 2008 14:35:37 +0000 Received: from [192.168.1.105] ([68.50.99.121]) by OMTA04.emeryville.ca.mail.comcast.net with comcast id oEbb1a00D2d8Sh88QEbcPe; Sun, 07 Dec 2008 14:35:37 +0000 Message-ID: <493BDF39.3040001@christopherschultz.net> Date: Sun, 07 Dec 2008 09:35:37 -0500 From: Christopher Schultz User-Agent: Thunderbird 2.0.0.18 (Windows/20081105) MIME-Version: 1.0 To: Tomcat Users List Subject: Re: configure JNDI to avoid error "Last packet sent to the server was xxxxx ms ago" References: <841320.65911.qm@web81104.mail.mud.yahoo.com> In-Reply-To: <841320.65911.qm@web81104.mail.mud.yahoo.com> X-Enigmail-Version: 0.95.7 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Bob (why not?), removeps-groups@yahoo.com wrote: > The second message -- connection has already been closed -- most likely arises from my code structure, which is: > > Connection connection = null; > PreparedStatement prepStmt = null; > try > { > Connection connection = getConnection(); > PreparedStatement prepStmt = connection.prepareStatement(...); > ... > } > finally > { > if (prepStmt != null) prepStmt.close(); > if (connection != null) connection.close(); > } You should use try/catch blocks around the calls to your close methods. Otherwise, exceptions thrown in your main try/catch block might be masked by close errors. You want to make sure the original exception gets thrown, not a secondary one. > The call to getConnection() in the try block gets a connection from > the pool. But the server has closed this connection. Therefore the > call to prepareStatement throws a SQLException which is the last > packet exception. This is what validationQuery is supposed to fix. When properly configured, you don't have to worry about this. > But it's just too much code to write! So don't write it that way. It's not even remotely necessary. The finally block will still run "during" an exception throw. That's the point of the finally clause. Just let the original exception be thrown by the runtime by catching and logging the secondary one. > I removed minEvictableIdleTimeMillis and testWhileIdle. I think that's a good idea. > Is there any doc about the ping in "/*ping*/ select 1"? Search for "ping" in the Connector/J documentation. I could only find it in the changelog, unfortunately. > And yes, I got these errors even without my driver. That's good to know. - -chris -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iEUEARECAAYFAkk73zkACgkQ9CaO5/Lv0PC91QCeKd8cDR9xrepFmWDSTtpB2i5k U6sAmKhTS2c/rbAAxeQtRarMc7lsDDQ= =a2y4 -----END PGP SIGNATURE----- --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org For additional commands, e-mail: users-help@tomcat.apache.org