Home  >  Article  >  Database  >  Java/JSP程序连接不上Mysql驱动问题解决方法

Java/JSP程序连接不上Mysql驱动问题解决方法

WBOY
WBOYOriginal
2016-06-07 15:39:521176browse

错误提示: java.lang.ClassNotFoundException: com.mysql.jdbc.Driver at java.net.URLClassLoader$1.run(URLClassLoader.java:366) at java.net.URLClassLoader$1.run(URLClassLoader.java:355) at java.security.AccessController.doPrivileged(Native Me

错误提示:

java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:188)
at TestDBConn.main(TestDBConn.java:30)


方法一:(针对Java程序)

    将mysql-connector-java-5.1.34-bin.jar这个包进行环境变量的配置:“我的电脑->属性->环境变量->CLASSPATH” 即可。

    PS:记住在前一个变量前加英文的分号;


方法二:(针对Java程序)

    方法一不行的情况下,将mysql-connector-java-5.1.34-bin.jar包放置到jdk安装目录的\jre\lib\ext下即可。


方法三:(针对JSP)

    将mysql-connector-java-5.1.34-bin.jar放置在Tomcat(其他服务器自行对应)的lib目录下,重启服务器即可。

Statement:
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