Home > Database > Mysql Tutorial > body text

JDBC连接MySQL出现的问题

WBOY
Release: 2016-06-07 18:03:09
Original
993 people have browsed it

采用JDBC连接MySQL数据库,JDBC驱动已经添加到eclipse的项目构建路径里了,按理来说应该一切正常。运行项目后提示“无法加载驱动”。

环境:

JDK 1.6.0_22+eclipse+MySQL5.0.22+mysql-connector-java-5.1.7-bin.jar



采用JDBC连接MySQL数据库,JDBC驱动已经添加到eclipse的项目“构建路径”里了,按理来说应该一切正常。运行项目后提示“无法加载驱动”。

最后解决的方法是,将mysql-connector-java-5.1.7-bin.jar放到"D:\Java\jdk1.6.0_22\jre\lib\ext”中,然后再编译运行上面的程序,就成功了。至于为什么,我还不知道。



貌似在“构建路径”中不加入驱动也可以,只要“%java_home%\jre\lib\ext”中有驱动就可以了。
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template