简体   繁体   English

Tomcat 6找不到mysql驱动

[英]Tomcat 6 can't find mysql driver

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. 突然我的小应用程序找不到mysql驱动程序。 And i don't understand why (really I've checked everything) 我不明白为什么(我真的检查了一切)

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以及从synaptics packadge管理器安装的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以查看它是否可以隐身,但它不是:(

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. 在这种情况下,它是管理数据源的Tomcat。 Thus, with placing the driver in Tomcat/lib you'll be fine. 因此,将驱动程序放在Tomcat/lib可以了。

Apart from that, you told you're using Ubuntu. 除此之外,你告诉过你正在使用Ubuntu。 It ships by default with a GNU JDK. 默认情况下它带有GNU JDK。 I would only highly recommend that you ensure that you get rid of it and install the Sun JDK instead. 我强烈建议你确保你摆脱它并安装Sun JDK。 The GNU JDK is cluttered of bugs which may cause at first sight unexplainable problems. GNU JDK杂乱无章,可能会导致乍一看无法解释的问题。 Hope you take this into consideration. 希望你考虑到这一点。

Try putting the MySQL JDBC driver in $CATALINA_HOME/lib and restart the web server. 尝试将MySQL JDBC驱动程序放在$CATALINA_HOME/lib并重新启动Web服务器。 Also, make sure the tomcat user (or whatever user you are running tomcat as) has permissions to read it. 此外,请确保tomcat用户(或您运行tomcat的任何用户)具有读取它的权限。

从以下链接http://sqlworkbench.mgm-tp.com/viewvc/trunk/sqlworkbench/junit/mysql-connector-java-5.1.13-bin下载“mysql-connector-java-5.1.13-bin.jar” .jar?revision = 2294&pathrev = 2294并将其复制到“Tomcat / lib”文件夹即...“$ CATALINA_HOME / lib”文件夹并重启Tomcat

Add the jar file in tomcat lib. 在tomcat lib中添加jar文件。 I think you can delete the jar file from application's WEB-INF/lib, because then there might be two definitions for one class. 我认为你可以从应用程序的WEB-INF / lib中删除jar文件,因为那样一个类可能有两个定义。 So just copy the jar file in tomcat lib. 所以只需复制tomcat lib中的jar文件即可。 hope this helps. 希望这可以帮助。 :) :)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM