Article View: borland.public.jbuilder.java.language
Article #171Re: changing class path at run time
From: George Xavier
Date: Sat, 01 Apr 2006 02:28
Date: Sat, 01 Apr 2006 02:28
83 lines
3774 bytes
3774 bytes
Yes, this works. Thank you.
I guess my mental block was here : "...you have to use the driver instance
itself in this scenario,
not the DriverManager whose class loader will never know about the
dynamically loaded class .....".
Anyway to get back to the issue which started this all: looks like the
runtime never revisits the value of java.class.path after the VM has
started. Wonder why.
Thanks again.
George X.
P.S Sorry I accidentally emailed you instead of the newsgroup in posting my
reply.
"Paul Furbacher [TeamB]" <pfurbacher@mac.com> wrote in message
news:442b51bb$1@newsgroups.borland.com...
> Try this:
>
> public void getConnection(
> String classname,
> String filename,
> String dbUrl,
> Properties props) {
> try {
> File f = new File(filename);
> URL[] urlList = new URL[] { f.toURL() };
> URLClassLoader cld =
> new URLClassLoader(
> urlList,
> this.getClass().getClassLoader());
> Driver driver =
> (Driver)cld.loadClass(classname).newInstance();
> Connection connection = driver.connect(dbUrl, props);
> /* instead of
> Connection connection =
> DriverManager.getConnection(dbUrl, props);
> */
> }
> catch (Exception ex) {
> ex.printStackTrace();
> }
> }
>
>
> What I missed was the fact that you have to use
> the driver instance itself in this scenario, not
> the DriverManager whose class loader will never
> know about the dynamically loaded class ... at least
> I think that's the explanation. [Feel free to correct
> me if I'm wrong.]
>
> [Thanks to the Cayenne contributors, Andrei Adamchik in particular,
> for this solution. If you want to see it yourself, see the class,
> org.objectstyle.cayenne.conn.DriverDataSource. It's unfortunate
> that Cayenne is not more widely known -- my gut feeling is that
> it's a heck of a lot smoother an experience than Hibernate, which
> to me is very quirky. Cayenne has just admitted as a Jakarta
> Incubator project.
>
> http://incubator.apache.org/projects/cayenne.html
>
> I'm hoping that will boost its prominence.]
>
>
> --
>
>
> Paul Furbacher (TeamB)
>
> Save time, search the archives:
> http://info.borland.com/newsgroups/ngsearch.html
>
> Is it in Joi Ellis's Faq-O-Matic?
> http://www.visi.com/~gyles19/fom-serve/cache/1.html
>
> Finally, please send responses to the newsgroup only.
> That means, do not send email directly to me.
> Thank you.
Technical Details
Message-ID:
<442de557@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!news.belwue.de!LF.net!newsgroups.borland.com!not-for-mailReferences:
<442953d2$1@newsgroups.borland.com> <44296071$1@newsgroups.borland.com> <4429630f@newsgroups.borland.com> <4429a3e5@newsgroups.borland.com> <4429e83e$1@newsgroups.borland.com> <442afca7$1@newsgroups.borland.com> <442b51bb$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: f74b3,93e0a6dd5feccd47 X-Google-Attributes: gidf74b3,public X-Google-Language: ENGLISH,ASCII-7-bit From: "George Xavier" <NOgxSPAM@xgeorge.com> Newsgroups: borland.public.jbuilder.java.language References: <442953d2$1@newsgroups.borland.com> <44296071$1@newsgroups.borland.com> <4429630f@newsgroups.borland.com> <4429a3e5@newsgroups.borland.com> <4429e83e$1@newsgroups.borland.com> <442afca7$1@newsgroups.borland.com> <442b51bb$1@newsgroups.borland.com> Subject: Re: changing class path at run time Date: Fri, 31 Mar 2006 21:28:32 -0500 Lines: 85 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.2180 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 X-RFC2646: Format=Flowed; Response NNTP-Posting-Host: 70.21.147.88 Message-ID: <442de557@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1143858519 70.21.147.88 (31 Mar 2006 18:28:39 -0700) Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!news.belwue.de!LF.net!newsgroups.borland.com!not-for-mail