java Tomcat 6 找不到 mysql 驱动程序
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1733106/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Tomcat 6 can't find mysql driver
提问by fmsf
There is a similar question here but regarding the class path. ClassNotFoundException com.mysql.jdbc.Driver
这里有一个类似的问题,但关于类路径。 ClassNotFoundException com.mysql.jdbc.Driver
I've had everything working great until some days ago. Suddenly my little application can't find the mysql driver. And i don't understand why (really I've checked everything)
直到几天前,我的一切都运行良好。我的小应用突然找不到mysql驱动了。我不明白为什么(我真的检查了一切)
I got the driver jar in the WEB-INF/lib, but tomcat just seems unable to find it.
我在 WEB-INF/lib 中找到了驱动程序 jar,但是 tomcat 似乎无法找到它。
Anyone got any ideas why? I'm using Ubuntu with tomcat 6 and mysql installed from the synaptics packadge manager
有人知道为什么吗?我正在使用 Ubuntu 和从突触包管理器安装的 tomcat 6 和 mysql
The error that is giving is:
给出的错误是:
ClassNotFoundException: com.mysql.jdbc.Driver
I've even changed the permissions into 777 to see if it could be invisibile, but it isn't :(
我什至将权限更改为 777 以查看它是否可以不可见,但它不是 :(
回答by BalusC
If you created a datasource which requires this driver, then it should be placed directly in the classpath of the container which manages the datasource. In this case, it's Tomcat which manages the datasource. Thus, with placing the driver in Tomcat/libyou'll be fine.
如果您创建了需要此驱动程序的数据源,则应将其直接放置在管理数据源的容器的类路径中。在这种情况下,管理数据源的是 Tomcat。因此,将驱动程序放入Tomcat/lib您会没事的。
Apart from that, you told you're using Ubuntu. It ships by default with a GNU JDK. I would only highly recommend that you ensure that you get rid of it and install the Sun JDK instead. The GNU JDK is cluttered of bugs which may cause at first sight unexplainable problems. Hope you take this into consideration.
除此之外,你告诉你正在使用 Ubuntu。默认情况下,它随 GNU JDK 一起提供。我只强烈建议您确保摆脱它并安装 Sun JDK。GNU JDK 充满了错误,这些错误可能会导致乍一看无法解释的问题。希望你考虑到这一点。
回答by Asaph
Try putting the MySQL JDBC driver in $CATALINA_HOME/liband restart the web server. Also, make sure the tomcat user (or whatever user you are running tomcat as) has permissions to read it.
尝试放入 MySQL JDBC 驱动程序$CATALINA_HOME/lib并重新启动 Web 服务器。此外,请确保 tomcat 用户(或您运行 tomcat 的任何用户)具有读取它的权限。
回答by Senthil Kumar
Add the jar file in tomcat lib. I think you can delete the jar file from application's WEB-INF/lib, because then there might be two definitions for one class. So just copy the jar file in tomcat lib. hope this helps. :)
在tomcat lib中添加jar文件。我认为您可以从应用程序的 WEB-INF/lib 中删除 jar 文件,因为这样一个类可能有两个定义。所以只需将 jar 文件复制到 tomcat lib 中即可。希望这可以帮助。:)
回答by Fathah Rehman P
Download "mysql-connector-java-5.1.13-bin.jar" from following link http://sqlworkbench.mgm-tp.com/viewvc/trunk/sqlworkbench/junit/mysql-connector-java-5.1.13-bin.jar?revision=2294&pathrev=2294and copy it to "Tomcat/lib" folder ie..."$CATALINA_HOME/lib" folder and restart Tomcat
从以下链接下载“mysql-connector-java-5.1.13-bin.jar” http://sqlworkbench.mgm-tp.com/viewvc/trunk/sqlworkbench/junit/mysql-connector-java-5.1.13-bin .jar?revision=2294&pathrev=2294并将其复制到“Tomcat/lib”文件夹即...“$CATALINA_HOME/lib”文件夹并重新启动Tomcat

