问题描述
我正在尝试创建到我的数据库的连接,当我使用 main 方法测试我的代码时,它可以无缝地工作.但是,当尝试通过 Tomcat 7 访问它时,它失败并显示错误:
I am trying to create a connection to my database, when I put test my code using the main method, it works seamlessly. However, when trying to access it through Tomcat 7, it fails with error:
我正在使用池化.我在 WEB-INF/lib 和 .classpath 中放入了 mysql 连接器 (5.1.15)、dbcp (1.4) 和 pool(1.4.5) 库.我正在使用 Eclipse IDE.我的数据库驱动程序代码是:
I am using pooling. I put in mysql connector (5.1.15), dbcp (1.4) , and pool(1.4.5) libraries in WEB-INF/lib and in .classpath as well. I am using Eclipse IDE. My code for the database driver is:
我的堆栈跟踪的开始:
是什么导致了这个错误?
What is causing this error?
推荐答案
尝试将驱动程序 jar 放在服务器 lib 文件夹中.($CATALINA_HOME/lib)
Try putting the driver jar in the server lib folder. ($CATALINA_HOME/lib)
我相信甚至在应用程序实例化之前就需要设置连接池.(至少在 Jboss 中是这样的)
I believe that the connection pool needs to be set up even before the application is instantiated. (At least that's how it works in Jboss)
这篇关于如何修复:“找不到适合 jdbc:mysql://localhost/dbname 的驱动程序";使用池时出错?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!