[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.platform.rcp] Re: database connection within a RCP?

Nico Bruehl wrote:
as as test you could try

Driver d = org.firebirdsql.jdbc.FBDriver();
d.getConnection("jdbc:firebirdsql:bln9y22c/3050:c://fi
rebird/db/prozerf.gdb", props);


but this is not very dynamic.


yep, thanks to you too :)
I just needed to get the driver loaded when exported to a standalone app, so I didn't care about dynamic, yet :)

I may try the method as described at http://www.kfu.com/~nsayer/Java/dyn-jdbc.html ...

Since the database connection is essential but not the most important point to work on right now I will leave it as it works right now :)
I got a more difficult problem right now but that will be posted in a new thread hehe :)

thanks again,
nico


--
View in EZ forum: http://www.eclipsezone.com/eclipse/forums/m91955887.html


To be honest, you are not loading the driver dynamically. Your driver is present in the classpath when your application is started. Therefore the driver manager technique should work.

I suspect you must be putting your driver somewhere improper and its being loaded by some othermechanism before the eclipse classloader can load it. Your problem is a simple mistake somewhere. Your thinking was correct all along as this should work.


Try this; modify your code above

java.lang.System.out.println("Local classloader= " + getClass().getClassloader());

Driver d = org.firebirdsql.jdbc.FBDriver();

java.lang.System.out.println("Driver classloader= " + d.getClass().getClassloader());


Lets see who is really loading your driver. Those two should be the same. Hmm, oops. Now that I write the code I can already see the problem.


DriverManager.getClassloader() is going to be different from both of those since its loaded by the main classloader whereas each plugin gets its own classloader...

You'll have to stick with the technique I showed you earlier but you can get a bit more dynamic with

Class cls = class.forName("org.firebirdsql.jdbc.FBDriver");
Driver d = (Driver) cls.newInstance();

and let the user enter a URL to the jar file containing the driver they want if you are letting the user supply their own driver.



CL