java - 如何通过Eclipse RCP连接Mysql

标签 java mysql eclipse rcp

我正在尝试通过 RCP 项目连接到 mysql 数据库。我下载了 Mysql Jconnect 文件。解压到一个文件夹。按照文档中的说明设置类路径变量。我仍然无法连接到 Mysql。 我收到这个错误

SQLException: No suitable driver found for jdbc:mysql://localhost:3306/test
SQLState: 08001
VendorError: 0

然后我尝试在项目中添加 mysql-connect jar 文件作为外部 jar 文件,仍然没有成功。尝试将其添加为用户库,但没有任何反应。

最后,我创建了一个“来自现有 jar 文件的插件项目”选项,并将 mysql-connect 用作​​ jar 文件。然后在我的 RCP 项目中,我将这个插件添加为依赖插件,但结果相同。

我绝对确定代码,错误在类路径中。我该如何解决。

我的配置是:

操作系统:Ubuntu 10.04

Mysql版本:5.2.1

eclipse :3.5

我试过把文件放在/usr/bin 目录下,那也没用...

最佳答案

不是一个完整的答案,但是 this thread确实提到:

After rechecking everything I found that mysql configuration on the second computer was not to listen for network connections, after fixing that, (almost) all started to work fine

P.S. but anyways, reading that there is no suitable driver it is hard to guess, that the driver is found but failed to connect :)

所以这可能不是路径或类路径问题,而是 mysql 配置问题。


实际上 OP 在评论中确认这是一个类路径问题:

This thing finally worked. I copied the mysql-connect jar file into the project folder and added it to the runtime classpath of plugin.xml file.
The important thing here was I had to just enter the file name and not the absolute path.

关于java - 如何通过Eclipse RCP连接Mysql,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3293321/

相关文章:

java - Spring Tool Suite:“属性”中的“部署程序集”选项

Java声明变量

java - Clojure 中的类型化持久数据结构,用 Java 完成?

java - 适用于 Android 2.3.3 的 Xperia X10 SDK 插件

asp.net - Mysql 与 Asp.net

php - 有没有办法在动态内容中使用 css Sprite ?

mysql - Zend_Db 使用多个数据库?

java - 如何检测树中的循环引用?

eclipse - 我可以将 eclipse 主题更改为看起来像 netbeans 吗?

java - 缺少源文件的 Eclipse Java 调试