1

I've inherited a project (and I have absolutly no experience of Java) and I'm rather stuck.

We have a server running redhat, which I needed to update one of the jar files. So I simply copied up the updated file and restarted the service for that file. However this process has worked on our other server I did that too but on this one it comes up with the below in the log file.

Exception: com.mysql.jdbc.Driver
SQLException: No suitable driver found for jdbc:mysql://localhost:3306/dbanme

The jar files are uploaded to a folder in the root of the website and within that jar folder is a lib folder where mysql-connector-java-5.1.6-bin.jar is located.

Does anyone know what I could be missing as I'm a newbie to linux aswell.

Thanks in advance

4

2 回答 2

2

java.sql.SQLException:找不到合适的驱动程序

此异常可能有 2 个原因:

  1. 根本没有加载 JDBC 驱动程序。
  2. URL 不匹配任何加载的 JDBC 驱动程序。

由于驱动程序似乎已加载,因此该 URL 在该计算机上似乎无效:

jdbc:mysql://localhost:3306/dbname

您是否在该机器上的端口 3306 上运行和侦听 mysql。还要确保你在那里 hte schema dbname。

于 2013-05-15T09:36:25.327 回答
0

您只需要设置:

[jdbc:mysql://localhost/dbanme] 

代替

[jdbc:mysql://localhost:3306/dbanme]

因为java编译器默认理解一个端口3306,所以“localhost:”后面不需要填写“3306”

于 2014-01-15T06:32:36.973 回答