Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Eclipse plugin: Trying to load JDBC Driver via Class.forName("...")

Reply
Thread Tools

Eclipse plugin: Trying to load JDBC Driver via Class.forName("...")

 
 
georg.hartner@gmail.com
Guest
Posts: n/a
 
      07-27-2006
Hi, I'm trying to write an eclipse plugin for Social Networks'
Visualization. Therefore I need a Database Connection to an Oracle
Database. I added the Driver JAR to the classpath and did all the other
usual DB Connection stuff, but it always throws a
ClassDefNotFoundException when I try to load the Driver via
Class.ForName(...).

Any solutions? (I guess its an easy question for people used to write
eclipse plugins using external libraries )

Code (called out of a MultiPageEditor via Button ActionHandler - still
a bit messed up, sorry ):
------------------------------------------------
public void generateData(Model md) {
try {
//DriverManager.registerDriver(new
oracle.jdbc.driver.OracleDriver());
Class.forName("oracle.jdbc.driver.OracleDriver");
} catch (Exception e1) {
e1.printStackTrace();
}
try {
Connection conn =
DriverManager.getConnection("jdbcracle:vcoeorad/vcoe",un,pw);
...........
} catch (SQLException e) {
e.printStackTrace();
}
}
--------------------------------------------------
Exception:
--------------------------------------------------
java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver
at
org.eclipse.osgi.framework.internal.core.BundleLoa der.findClass(BundleLoader.java:407)
at
org.eclipse.osgi.framework.internal.core.BundleLoa der.findClass(BundleLoader.java:352)
at
org.eclipse.osgi.internal.baseadaptor.DefaultClass Loader.loadClass(DefaultClassLoader.java:83)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at util.DataImporter.generateData(DataImporter.java:4 0)
at snv.ui.GeneratorComposite$1.mouseDown(GeneratorCom posite.java:95)
at
org.eclipse.swt.widgets.TypedListener.handleEvent( TypedListener.java:133)
at org.eclipse.swt.widgets.EventTable.sendEvent(Event Table.java:66)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.ja va:92
at
org.eclipse.swt.widgets.Display.runDeferredEvents( Display.java:334
at org.eclipse.swt.widgets.Display.readAndDispatch(Di splay.java:296
at org.eclipse.ui.internal.Workbench.runEventLoop(Wor kbench.java:1914)
at org.eclipse.ui.internal.Workbench.runUI(Workbench. java:187
at
org.eclipse.ui.internal.Workbench.createAndRunWork bench(Workbench.java:419)
at
org.eclipse.ui.PlatformUI.createAndRunWorkbench(Pl atformUI.java:149)
at
org.eclipse.ui.internal.ide.IDEApplication.run(IDE Application.java:95)
at
org.eclipse.core.internal.runtime.PlatformActivato r$1.run(PlatformActivator.java:7
at
org.eclipse.core.runtime.internal.adaptor.EclipseA ppLauncher.runApplication(EclipseAppLauncher.java: 92)
at
org.eclipse.core.runtime.internal.adaptor.EclipseA ppLauncher.start(EclipseAppLauncher.java:6FEHLER
BEIM LADEN DES TREIBERS!
---------------------------------------------

Please help! Rescuer gets a beer when in Vienna!

Gg

 
Reply With Quote
 
 
 
 
Moiristo
Guest
Posts: n/a
 
      07-27-2006
wrote:
> Code (called out of a MultiPageEditor via Button ActionHandler - still
> a bit messed up, sorry ):
> ------------------------------------------------
> public void generateData(Model md) {
> try {
> //DriverManager.registerDriver(new
> oracle.jdbc.driver.OracleDriver());
> Class.forName("oracle.jdbc.driver.OracleDriver");
> } catch (Exception e1) {
> e1.printStackTrace();
> }



The classname is alright, so it must mean that you've incorrectly set up
the library. Be aware that you must add the jar itself to the classpath,
not the directory containing it.
 
Reply With Quote
 
 
 
 
georg.hartner@gmail.com
Guest
Posts: n/a
 
      07-27-2006

>
> The classname is alright, so it must mean that you've incorrectly set up
> the library. Be aware that you must add the jar itself to the classpath,
> not the directory containing it.


Thanks for your immediate reply. I think i added it correctly (in the
build path ("Add External JARs") as well as I hooked the checkbox for
the export. I've often written programs using JDBC or orther external
libraries. I think it's an eclipse specific issue corresponding to PDE
or OSGi.

I checked what you meant but it still doesn't work . Sorry. Next one?


 
Reply With Quote
 
georg.hartner@gmail.com
Guest
Posts: n/a
 
      07-27-2006
"SOLVED"! I think I found a suitable solution. I had to extract the jar
file somewhere in the plugin directory and add the folder to the
classpath through Manifest.MF - Runtime Configuration - Classpath -
Add.

Thanks
G

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: [JDBC] JDBC Driver and timezones Lew Java 0 05-19-2010 03:33 PM
How to parse the jdbc driver name from the jdbc .jar file Bruce Java 4 03-25-2006 12:01 PM
oracle.jdbc.OracleDriver vs oracle.jdbc.driver.OracleDriver Betty Java 1 05-21-2005 05:15 PM
Cannot load JDBC driver class 'null' exception leni Java 1 02-11-2005 11:12 PM
Cannot load JDBC Driver class 'null' with TOMCAT Frank Marx Java 1 08-06-2003 03:45 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57