2011-02-01 21 views
1

すべて、Class.forName("com.mysql.jdbc.Driver")を使用してドライバクラスをロードしようとしたとき、私はcom.mysql.jdbc.Driver例外を取得していますは、Eclipse RCP IDE

でMySQLを接続できません。カスタムEclipseプラグインを作成し、カスタムEclipseプラグインでデータベースにアクセスしたいと思っています。私は2つのオプションは、両方のは明らかに失敗し、次の試してみました


1>
2 Eclipseプラグインのビルド・パスにmysqlの接続のJARファイルを追加する>ライブラリとしてコネクタのJARファイルを追加し、プラグインの実行時のクラスパス

に追加します

誰も私にこれを助けてくれますか?ここで

はログです:

java.lang.ClassNotFoundException: com.mysql.jdbc.Driver 
    at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:506) 
    at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:422) 
    at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:410) 
    at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:107) 
    at java.lang.ClassLoader.loadClass(Unknown Source) 
    at java.lang.Class.forName0(Native Method) 
    at java.lang.Class.forName(Unknown Source) 
    at draft1.set1.utility.DatabaseUpdatesUtility.commitPerspectiveToDB(DatabaseUpdatesUtility.java:48) 
    at draft1.set1.display.DomainEditor.doSaveAs(DomainEditor.java:57) 
    at org.eclipse.ui.internal.SaveAsAction.run(SaveAsAction.java:64) 
    at org.eclipse.jface.action.Action.runWithEvent(Action.java:498) 
    at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:584) 
    at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:501) 
    at org.eclipse.jface.action.ActionContributionItem$5.handleEvent(ActionContributionItem.java:411) 
    at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84) 
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1053) 
    at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4066) 
    at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3657) 
    at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2640) 
    at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2604) 
    at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2438) 
    at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:671) 
    at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332) 
    at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:664) 
    at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149) 
    at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:115) 
    at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196) 
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110) 
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79) 
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:369) 
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179) 
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) 
    at java.lang.reflect.Method.invoke(Unknown Source) 
    at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:619) 
    at org.eclipse.equinox.launcher.Main.basicRun(Main.java:574) 
    at org.eclipse.equinox.launcher.Main.run(Main.java:1407) 
    at org.eclipse.equinox.launcher.Main.main(Main.java:1383) 
java.sql.SQLException: No suitable driver found for jdbc:mysql://localhost:3306/mysql 
    at java.sql.DriverManager.getConnection(Unknown Source) 
    at java.sql.DriverManager.getConnection(Unknown Source) 
    at draft1.set1.utility.DatabaseUpdatesUtility.commitPerspectiveToDB(DatabaseUpdatesUtility.java:53) 
    at draft1.set1.display.DomainEditor.doSaveAs(DomainEditor.java:57) 
    at org.eclipse.ui.internal.SaveAsAction.run(SaveAsAction.java:64) 
    at org.eclipse.jface.action.Action.runWithEvent(Action.java:498) 
    at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:584) 
    at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:501) 
    at org.eclipse.jface.action.ActionContributionItem$5.handleEvent(ActionContributionItem.java:411) 
    at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84) 
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1053) 
    at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4066) 
    at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3657) 
    at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2640) 
    at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2604) 
    at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2438) 
    at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:671) 
    at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332) 
    at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:664) 
    at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149) 
    at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:115) 
    at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196) 
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110) 
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79) 
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:369) 
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179) 
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) 
    at java.lang.reflect.Method.invoke(Unknown Source) 
    at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:619) 
    at org.eclipse.equinox.launcher.Main.basicRun(Main.java:574) 
    at org.eclipse.equinox.launcher.Main.run(Main.java:1407) 
    at org.eclipse.equinox.launcher.Main.main(Main.java:1383) 
+0

"com.mysql.jdbc.Driver例外"は何も意味しません。実際の例外とは何ですか?投稿を編集し、COMPLETEスタックトレースを追加してください。 –

+0

@Jim:スタックを追加 –

答えて

1

私はハウツーためhttp://wiki.eclipse.org/Create_and_Export_MySQL_JDBC_driver_bundleを参照して、MySQLドライバ用に独自のOSGiバンドルを作成することをお勧めします。その後、バンドルのplugin.xmlに作成されたmysql-bundleへの依存関係を設定する必要があります。

さらに、DriverManagerではなくDataSourceの実装であるOSGi環境で使用してください。