Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id 537B163266D for ; Thu, 3 Jun 2010 03:23:34 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 87970-04 for ; Thu, 3 Jun 2010 06:23:26 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from www.postnewspapers.com.au (www.postnewspapers.com.au [202.4.227.11]) by mail.postgresql.org (Postfix) with ESMTP id C0DE763264E for ; Thu, 3 Jun 2010 03:23:26 -0300 (ADT) Received: from mail.postnewspapers.com.au (202-89-185-120.static.dsl.amnet.net.au [202.89.185.120]) by www.postnewspapers.com.au (Postfix) with ESMTP id 1DA27A2AB; Thu, 3 Jun 2010 14:23:24 +0800 (WST) Received: from localhost (localhost [127.0.0.1]) by mail.postnewspapers.com.au (Postfix) with ESMTP id 160EAAF43B; Thu, 3 Jun 2010 14:21:36 +0800 (WST) X-Virus-Scanned: Debian amavisd-new at postnewspapers.com.au Received: from mail.postnewspapers.com.au ([127.0.0.1]) by localhost (mail.postnewspapers.com.au [127.0.0.1]) (amavisd-new, port 10024) with LMTP id jFAuCkAt3qRd; Thu, 3 Jun 2010 14:21:30 +0800 (WST) Received: from [10.1.1.7] (124-148-251-30.dyn.iinet.net.au [124.148.251.30]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "Craig Ringer", Issuer "POST Certificate Authority" (verified OK)) by mail.postnewspapers.com.au (Postfix) with ESMTPSA id 7D1BBAE9AD; Thu, 3 Jun 2010 14:21:30 +0800 (WST) Message-ID: <4C074A53.9020004@postnewspapers.com.au> Date: Thu, 03 Jun 2010 14:23:15 +0800 From: Craig Ringer User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-GB; rv:1.9.1.9) Gecko/20100317 Thunderbird/3.0.4 MIME-Version: 1.0 To: Lew CC: pgsql-jdbc@postgresql.org Subject: Re: jdbc works in java app, fails in servlet: "no suitable jdbc found" References: <8CCD02714A2791E-E2C-7A83@webmail-m042.sysops.aol.com> <4C05F409.7060805@postnewspapers.com.au> In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-0.011 tagged_above=-10 required=5 tests=BAYES_40=-0.001, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201006/36 X-Sequence-Number: 20606 On 3/06/2010 6:58 AM, Lew wrote: >> You can use the classloader that loaded the currently running object >> with: >> >> this.getClass().getClassLoader().loadClass('org.postgresql.Driver'); > > The driver should be loaded in a static context, not an instance > context. Furthermore, that code as shown will not compile. Oops, wrong quotes. Point. > Further > furthermore, I see nothing in the documentation for > 'ClassLoader#loadClass()' that promises to initialize the class, unlike > 'Class.forName()'. If the class is not initialized, the driver won't > register with the 'DriverManager'. I think you're selling a pig in a > poke here. Fair call - the beahaviour would depend on the classloader, and probably shouldn't be assumed. > Go with the Tomcat way and forget the kludgey direct uses of Java > reflection. The fact that I haven't done much in servelet environments kinda shows, I suspect. JNDI is certainly the way to go based on what you referred to. -- Craig Ringer