Return-Path: X-Original-To: apmail-tomcat-users-archive@www.apache.org Delivered-To: apmail-tomcat-users-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id A9FFD4E87 for ; Wed, 11 May 2011 13:38:10 +0000 (UTC) Received: (qmail 16836 invoked by uid 500); 11 May 2011 13:38:07 -0000 Delivered-To: apmail-tomcat-users-archive@tomcat.apache.org Received: (qmail 16766 invoked by uid 500); 11 May 2011 13:38:07 -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 16757 invoked by uid 99); 11 May 2011 13:38:07 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 11 May 2011 13:38:07 +0000 X-ASF-Spam-Status: No, hits=0.7 required=5.0 tests=RCVD_IN_DNSWL_NONE,SPF_NEUTRAL X-Spam-Check-By: apache.org Received-SPF: neutral (nike.apache.org: local policy) Received: from [76.96.27.227] (HELO qmta12.emeryville.ca.mail.comcast.net) (76.96.27.227) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 11 May 2011 13:37:58 +0000 Received: from omta14.emeryville.ca.mail.comcast.net ([76.96.30.60]) by qmta12.emeryville.ca.mail.comcast.net with comcast id iDVj1g0021HpZEsACDddEK; Wed, 11 May 2011 13:37:37 +0000 Received: from [192.168.1.201] ([69.143.109.145]) by omta14.emeryville.ca.mail.comcast.net with comcast id iDda1g01B38FjT18aDdchs; Wed, 11 May 2011 13:37:36 +0000 Message-ID: <4DCA9120.4050106@christopherschultz.net> Date: Wed, 11 May 2011 09:37:36 -0400 From: Christopher Schultz User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.17) Gecko/20110414 Thunderbird/3.1.10 MIME-Version: 1.0 To: Tomcat Users List Subject: Re: Override Driver Manager (DB Connections) through tomcat servers References: In-Reply-To: X-Enigmail-Version: 1.2a1pre Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Virus-Checked: Checked by ClamAV on apache.org -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Joji, On 5/11/2011 3:15 AM, Joji V J wrote: > Since few days I've noticed that some of the applications in the server > are using the device manager based database connections, causing too many > open connections with the database. Unfortunately I'm in no position to > instruct them to use the tomcat based datasource connections. So here it'll > of great help if you can provide me with configurations/tips to override the > java device manager based connections and pass them through the tomcat > resource driven datasource connections.. I can only think of one way to do this, and it requires the use of a SecurityManager (which may be more complicated than it's worth for you). Here's what you do: 1. Go into the class where you /want/ programmers to be able to obtain connections. Let's call that class ConnectionFactory, and assume there's a method called getConnection in it. Add this code: public Connection getConnection() throws ... { ... if(null != System.getSecurityManager()) { return AccessController.doPrivileged( new PrivilegedAction() { public Connection run() { // get your Connection object return the_connection; } } ); } else { // get your Connection object } } 2. Adjust your policy file such that the above code is allowed to make outgoing connections to your db. This ought to cause SecurityExceptions to be thrown whenever the DriverManager is used directly to obtain a connection. - -chris -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAk3KkSAACgkQ9CaO5/Lv0PCtVgCgqxvcAo12JU0P4pJXtzlV4yBK R5cAnjzh6BDKyG1W4/DBtS1Cz6MUzHHt =OUDy -----END PGP SIGNATURE----- --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org For additional commands, e-mail: users-help@tomcat.apache.org