Eclipse rcp - 如何加载jdbc驱动? [英] Eclipse rcp - how to load jdbc driver?
问题描述
我想知道有人可以给我一些关于如何执行以下操作的说明:
I was wondering if someone could give me some instructions on how to do the following:
- 如何将mysql连接JAR文件添加到Eclipse插件构建路径
- 如何将连接器JAR文件添加为库并添加到插件的运行时类路径
当尝试使用 Class.forName(com.mysql.jdbc.Driver)加载驱动程序类时,我正在收到com.mysql.jdbc.Driver异常
。我已经通过右键单击项目名称并选择添加库按钮将jdbc驱动程序添加到项目中。但是我发现在eclipse rcp项目中有一种不同的添加jdbc jar文件的方法。
I am getting com.mysql.jdbc.Driver exception when trying to load the Driver class using Class.forName("com.mysql.jdbc.Driver")
. I have added the jdbc driver to the project by right clicking on the project name and selecting add Library button. But I found out there for eclipse rcp project there is a different way of adding the jdbc jar file.
推荐答案
我从未在Eclipse中使用过mysql,但是我已经用postgres sql完成了。也许这将有助于您:
I've never used mysql with Eclipse, but i've done this with postgres sql. Maybe this will help you:
- 在软件包资源管理器中右键单击项目
- 构建路径
-
- 添加外部存档...
- 选择您的mysql jar存档
- 按确定
- 应该在库资源管理器下的引用的库中引用该库。现在尝试再次运行您的程序。
- Right-click project in Package explorer
- Build path
- Add external archives...
- Select your mysql jar archive
- Press OK
- The library should be now referenced in the "Referenced Librairies" under the Package explorer. Now try to run your program again.
这篇关于Eclipse rcp - 如何加载jdbc驱动?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!