Return-Path: Delivered-To: apmail-db-derby-user-archive@www.apache.org Received: (qmail 28044 invoked from network); 11 Nov 2005 23:21:21 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 11 Nov 2005 23:21:21 -0000 Received: (qmail 65014 invoked by uid 500); 11 Nov 2005 23:21:20 -0000 Delivered-To: apmail-db-derby-user-archive@db.apache.org Received: (qmail 64982 invoked by uid 500); 11 Nov 2005 23:21:19 -0000 Mailing-List: contact derby-user-help@db.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: List-Id: Reply-To: "Derby Discussion" Delivered-To: mailing list derby-user@db.apache.org Received: (qmail 64971 invoked by uid 99); 11 Nov 2005 23:21:19 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 11 Nov 2005 15:21:19 -0800 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests=UNPARSEABLE_RELAY X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: local policy) Received: from [192.18.98.34] (HELO brmea-mail-3.sun.com) (192.18.98.34) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 11 Nov 2005 15:21:11 -0800 Received: from phys-mpk-1 ([129.146.11.81]) by brmea-mail-3.sun.com (8.12.10/8.12.9) with ESMTP id jABNKv3F005286 for ; Fri, 11 Nov 2005 16:20:57 -0700 (MST) Received: from conversion-daemon.mpk-mail1.sfbay.sun.com by mpk-mail1.sfbay.sun.com (iPlanet Messaging Server 5.2 HotFix 1.24 (built Dec 19 2003)) id <0IPT00G01CM104@mpk-mail1.sfbay.sun.com> (original mail from David.Vancouvering@Sun.COM) for derby-user@db.apache.org; Fri, 11 Nov 2005 15:20:57 -0800 (PST) Received: from [129.144.89.64] (d-sfo07-89-64.SFBay.Sun.COM [129.144.89.64]) by mpk-mail1.sfbay.sun.com (iPlanet Messaging Server 5.2 HotFix 1.24 (built Dec 19 2003)) with ESMTP id <0IPT0089PCUX17@mpk-mail1.sfbay.sun.com> for derby-user@db.apache.org; Fri, 11 Nov 2005 15:20:57 -0800 (PST) Date: Fri, 11 Nov 2005 15:21:06 -0800 From: "David W. Van Couvering" Subject: Re: Question about using URLClassLoader and Derby In-reply-to: <43722A1E.4000402@sbcglobal.net> To: Derby Discussion , Binod P G Message-id: <43752762.2030605@sun.com> MIME-version: 1.0 Content-type: multipart/mixed; boundary="Boundary_(ID_+7JgTFzxGJjAh/aIqhNPJQ)" X-Accept-Language: en-us, en User-Agent: Mozilla Thunderbird 1.0.7 (Windows/20050923) References: <43722A1E.4000402@sbcglobal.net> X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N This is a multi-part message in MIME format. --Boundary_(ID_+7JgTFzxGJjAh/aIqhNPJQ) Content-type: text/plain; charset=ISO-8859-1; format=flowed Content-transfer-encoding: 7BIT Here's an answer from Binod, one of our app server engineers... Kathey Marsden wrote: > My goal is: > I want to use a specific version of Derby which I ship with my app and I > don't want to interfere with any other derby versions loaded in the > same JVM or have them interfere with me. I am creating a new > datasource in a separate URLClassLoader and using that for creating all > my connections. Are there other things I need to do to meet my goal? > I have a feeling it all must be more complex than it looks to me right now. > > Thanks > > Kathey > > Below is some code showing what I have done in playing with this so far. > > Method to load derby in separate loader and create datasource: > > private static DataSource newDataSource(ClassLoader loader, String > databaseName) throws Exception > { > DataSource ds = (DataSource) > loader.loadClass("org.apache.derby.jdbc.EmbeddedDataSource").newInstance(); > // setDatabaseName with reflection > Class[] argType = {String.class}; > String[] args = new String[] {databaseName}; > Method sh = ds.getClass().getMethod("setDatabaseName", argType); > sh.invoke(ds, args); > return ds; > > } > > // Calling program .... > ..... > URL[] urls = > new URL[]{new URL(derbyJarURLString)}; > System.out.println(urls[0].getFile()); > ClassLoader loader1 =new URLClassLoader(urls); > DataSource ds = newDataSource(loader1,"mydb;create=true"); > ds.getConnection(); > ... > > > --Boundary_(ID_+7JgTFzxGJjAh/aIqhNPJQ) Content-type: message/rfc822; name="Attached Message" Return-path: Received: from conversion-daemon.mpk-mail1.sfbay.sun.com by mpk-mail1.sfbay.sun.com (iPlanet Messaging Server 5.2 HotFix 1.24 (built Dec 19 2003)) id <0IPS00K01F0T39@mpk-mail1.sfbay.sun.com> for David.Vancouvering@Sun.COM; Fri, 11 Nov 2005 03:32:27 -0800 (PST) Received: from phys-biff-1 (phys-biff-1.India.Sun.COM [129.158.227.36]) by mpk-mail1.sfbay.sun.com (iPlanet Messaging Server 5.2 HotFix 1.24 (built Dec 19 2003)) with ESMTP id <0IPS00C60G21ZS@mpk-mail1.sfbay.sun.com> for David.Vancouvering@Sun.COM; Fri, 11 Nov 2005 03:32:27 -0800 (PST) Received: from conversion-daemon.biff-mail1.india.sun.com by biff-mail1.india.sun.com (iPlanet Messaging Server 5.2 HotFix 1.24 (built Dec 19 2003)) id <0IPS00K01G11RO@biff-mail1.india.sun.com> (original mail from Binod.Pg@Sun.COM) for David.Vancouvering@Sun.COM; Fri, 11 Nov 2005 17:02:22 +0530 (IST) Received: from Sun.COM (javasoft12.India.Sun.COM [129.158.229.168]) by biff-mail1.india.sun.com (iPlanet Messaging Server 5.2 HotFix 1.24 (built Dec 19 2003)) with ESMTP id <0IPS00LVDG1X5F@biff-mail1.india.sun.com>; Fri, 11 Nov 2005 17:02:22 +0530 (IST) Date: Fri, 11 Nov 2005 16:57:53 +0530 From: Binod P G Subject: Re: [Fwd: Question about using URLClassLoader and Derby] In-reply-to: <43723003.3090506@sun.com> To: "David W. Van Couvering" Cc: "Lance J. Andersen" , Amit Handa , Craig Russell Reply-to: Binod.Pg@Sun.COM Message-id: <43748039.5050602@Sun.COM> MIME-version: 1.0 Content-type: text/plain; charset=us-ascii Content-transfer-encoding: 7BIT X-Accept-Language: en-us, en User-Agent: Mozilla/5.0 (X11; U; SunOS sun4u; en-US; rv:1.4) Gecko/20041214 References: <43723003.3090506@sun.com> Original-recipient: rfc822;David.Vancouvering@Sun.COM David W. Van Couvering wrote On 11/09/05 10:51 PM,: > Hi, guys. Is there any helpful information you can provide Kathey? You > can respond to me or directly to derby-user@db.apache.org. If you load > one class with a classloader, will all other classes for objects created > by that class be loaded from the same classloader? If not, how do you > achieve what she is trying to accomplish? Make sure that there is only one URL classloader instance that has access to the derby jar files. And make sure that whenever a code accesses the datasource, it always go thru newDataSource method, then yes, it should work. - Binod. p.s: This is all assuming that derby code doent do any other interesting classloader mechanism inside :-). For example, it can use Thread's context classLoader to load some other part of derby that might break. > > Thanks! > > David > > > ------------------------------------------------------------------------ > > Subject: > Question about using URLClassLoader and Derby > From: > Kathey Marsden > Date: > Wed, 09 Nov 2005 08:55:58 -0800 > To: > Derby Discussion > > > My goal is: > I want to use a specific version of Derby which I ship with my app and I > don't want to interfere with any other derby versions loaded in the > same JVM or have them interfere with me. I am creating a new > datasource in a separate URLClassLoader and using that for creating all > my connections. Are there other things I need to do to meet my goal? > I have a feeling it all must be more complex than it looks to me right now. > > Thanks > > Kathey > > Below is some code showing what I have done in playing with this so far. > > Method to load derby in separate loader and create datasource: > > private static DataSource newDataSource(ClassLoader loader, String > databaseName) throws Exception > { > DataSource ds = (DataSource) > loader.loadClass("org.apache.derby.jdbc.EmbeddedDataSource").newInstance(); > // setDatabaseName with reflection > Class[] argType = {String.class}; > String[] args = new String[] {databaseName}; > Method sh = ds.getClass().getMethod("setDatabaseName", argType); > sh.invoke(ds, args); > return ds; > > } > > // Calling program .... > ..... > URL[] urls = > new URL[]{new URL(derbyJarURLString)}; > System.out.println(urls[0].getFile()); > ClassLoader loader1 =new URLClassLoader(urls); > DataSource ds = newDataSource(loader1,"mydb;create=true"); > ds.getConnection(); > ... > > > -- --Boundary_(ID_+7JgTFzxGJjAh/aIqhNPJQ) Content-type: text/x-vcard; charset=utf-8; name=david.vancouvering.vcf Content-transfer-encoding: 7BIT Content-disposition: attachment; filename=david.vancouvering.vcf begin:vcard fn:David W Van Couvering n:Van Couvering;David W org:Sun Microsystems, Inc.;Database Technology Group email;internet:david.vancouvering@sun.com title:Senior Staff Software Engineer tel;work:510-550-6819 tel;cell:510-684-7281 x-mozilla-html:TRUE version:2.1 end:vcard --Boundary_(ID_+7JgTFzxGJjAh/aIqhNPJQ)--