Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » HowTo load database-driver dynamically
HowTo load database-driver dynamically [message #320939] Thu, 04 October 2007 09:29 Go to next message
Eclipse UserFriend
Originally posted by: tobias.soloschenko.mxcit.de

Hello,

I've a little problem by loading driver at runtime, I posted it already in
another newsgroup but even there noone had an idea. So here is the
description:

---------

Hello,

Is there any way to add jars dynamically to the osgi context? I've got
the
problem to use a folder where users can add drivers and those drivers
have
to load dynamically. So I can't define it in plugin.xml > Runtime >
Classpath.

I'm using Spring in the rcp context and the request to any driver
classes
is delegated to the
org.eclipse.core.runtime.internal.adaptor.ContextFinder. The
ContextFinder itself looks into the classpath of the plugin where no
Drivers
are found and then the app crashes.

I heard about a ClassLoadingHook and tried it already with vm
arguments.

Thanks!
Re: HowTo load database-driver dynamically [message #321076 is a reply to message #320939] Mon, 08 October 2007 07:21 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: tobias.soloschenko.mxcit.de

The problem has to be solved soon. Is there no way to do this?

Greetings
Re: HowTo load database-driver dynamically [message #321178 is a reply to message #320939] Wed, 10 October 2007 19:12 Go to previous messageGo to next message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

Tobias Soloschenko wrote:
>
> I heard about a ClassLoadingHook and tried it already with vm arguments.

You implemented something with a ClassLoadingHook? and that didn't work?

Have you talked with the datatools project users?
http://www.eclipse.org/datatools/ I thought at least part of that
framework allowed one to pick a JDBC driver.

--
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Menu_Contributions
http://wiki.eclipse.org/Menus_Extension_Mapping
http://help.eclipse.org/help33/index.jsp?topic=/org.eclipse. platform.doc.isv/guide/workbench.htm


Re: HowTo load database-driver dynamically [message #321246 is a reply to message #321178] Fri, 12 October 2007 11:04 Go to previous message
Eclipse UserFriend
Originally posted by: tobias.soloschenko.mxcit.de

Hello,

no I can't find any documentation about those Hook's, so I solved it by
writing my own classLoader and set it as ContentClassLoader which uses the
URLClassLoader:

ExternalClassLoader myLoader = new ExternalClassLoader();
Thread.currentThread().setContextClassLoader(myLoader);

because I'm using a datapool called c3p0 with Spring and the sources of
c3p0 are free available I changed the programcode where they are locating
drivers with Class.forName("...") to
Class.forName("...",true,myClassLoader);

I configured the driverLoader to load drivers from the install-folder with
Platform.getInstallLocation().getURL().getFile()

Now I can put drivers into the eclipse directory (for testing) or into the
programfolder when the product has been exported and they are loaded
dynamically.

Thats a very dirty solution, may it is possible in a better way but how?

best regards

Tobias
Previous Topic:how to acess current project name
Next Topic:Listen for modification in workspace (delete/rename/move)
Goto Forum:
  


Current Time: Fri Jul 19 14:32:05 GMT 2024

Powered by FUDForum. Page generated in 0.03782 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top