[英]SQLException: No suitable driver found for jdbc:mysql://localhost:3306/dbname
I've inherited a project (and I have absolutly no experience of Java) and I'm rather stuck. 我继承了一个项目(而且我绝对没有Java的经验),但我很困惑。
We have a server running redhat, which I needed to update one of the jar files. 我们有一台运行redhat的服务器,我需要更新其中的jar文件。 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. jar文件被上载到网站根目录中的一个文件夹中,并且该jar文件夹中有一个lib文件夹,该文件夹位于mysql-connector-java-5.1.6-bin.jar。
Does anyone know what I could be missing as I'm a newbie to linux aswell. 有谁知道我可能是Linux新手,所以我可能会错过什么。
Thanks in advance 提前致谢
java.sql.SQLException: No suitable driver found java.sql.SQLException:找不到合适的驱动程序
This exception can have 2 causes: 此异常可能有2个原因:
Since the driver seems to be loaded , it look like that the URL is not valid on that machine: 由于驱动程序似乎已加载,因此该URL在该计算机上无效:
jdbc:mysql://localhost:3306/dbname JDBC:MySQL的://本地主机:3306 / DBNAME
Do you have mysql running and listening on port 3306 on that machine. 您是否在该计算机上的端口3306上运行并监听mysql。 Also make sure you hte schema dbname there.
还要确保在那里有模式dbname。
You need only set that: 您只需要设置:
[jdbc:mysql://localhost/dbanme]
instead of 代替
[jdbc:mysql://localhost:3306/dbanme]
Because java compiler default understand a port 3306, so no need to fill "3306" after "localhost:" 由于Java编译器默认了解端口3306,因此无需在“ localhost:”后填写“ 3306”
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.