我彻底疯了!!两天了没搞定呀!郁闷死了!Cannot load JDBC driver class 'null' 错误

tong82865 2004-09-11 10:31:44
Cannot load JDBC driver class 'null'

怎么搞的呀!!!

我已经在CLASSPATH环境变量里设置了mm.mysql-2.0.4-bin.jar
JAVA SDK 的LIB目录下也考了 mm.mysql-2.0.4-bin.jar文件
TOMCAT的common\lib目录下也考了mm.mysql-2.0.4-bin.jar文件
程序的WEB-INF\lib目录下也考了mm.mysql-2.0.4-bin.jar文件

郁闷就是提示Cannot load JDBC driver class 'null'

//////////////////////SERVER.XML////////////

<Context path="" docBase="xx" debug="0" reloadable="true" >
<Resource name="jdbc/movie" auth="Container" type="javax.sql.DataSource"/>

<ResourceParams name="jdbc/movie">

<parameter>
<name>factory</name>
<value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
</parameter>

<!-- Maximum number of dB connections in pool. Make sure you
configure your mysqld max_connections large enough to handle
all of your db connections. Set to 0 for no limit. 100
-->
<parameter>
<name>maxActive</name>
<value>100</value>
</parameter>

<!-- Maximum number of idle dB connections to retain in pool.
Set to 0 for no limit. 30
-->
<parameter>
<name>maxIdle</name>
<value>30</value>
</parameter>

<!-- Maximum time to wait for a dB connection to become available
in ms, in this example 10 seconds. An Exception is thrown if
this timeout is exceeded. Set to -1 to wait indefinitely.
-->
<parameter>
<name>maxWait</name>
<value>5000</value>
</parameter>

<!-- MySQL dB username and password for dB connections -->
<parameter>
<name>username</name>
<value>admin</value>
</parameter>
<parameter>
<name>password</name>
<value></value>
</parameter>

<!-- Class name for mm.mysql JDBC driver -->
<parameter>
<name>driverClassName</name>
<value>org.gjt.mm.mysql.Driver</value>
</parameter>

<!-- The JDBC connection url for connecting to your MySQL dB.
The autoReconnect=true argument to the url makes sure that the
mm.mysql JDBC Driver will automatically reconnect if mysqld closed the
connection. mysqld by default closes idle connections after 8 hours.
-->
<parameter>
<name>url</name>
<value>jdbc:mysql://localhost:3306/moves?autoReconnect=true</value>
</parameter>
</ResourceParams>
</Context>

//////////////////////WEB.XML////////////
<resource-ref>
<description>testDB</description>
<res-ref-name>jdbc/movie</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>


...全文
261 15 打赏 收藏 转发到动态 举报
写回复
用AI写文章
15 条回复
切换为时间正序
请发表友善的回复…
发表回复
tqc_2008 2004-09-11
  • 打赏
  • 举报
回复
up
angelheart 2004-09-11
  • 打赏
  • 举报
回复
网上找到的

解决:在%TOMCAT_HOME%\conf\Catalina\localhost下找到你的web应用对应的.xml文件,如test.xml,并在此文件的下添入代码:

<ResourceLink name="jdbc/mysql" global="jdbc/mysql" type="javax.sql.DataSourcer"/>

重启tomcat。

你的是服务器的全局JNDI资源,而用InitialContext去找server的resource当然找不到了,要想找到server的resource就得在web application中的context环境里加入一个指向该全局resource的ResourceLink。

global -->The name of the linked global resource in the global JNDI context.
name -->The name of the resource link to be created, relative to the java:comp/env context.?
type -->The fully qualified Java class name expected by the web application when it performs a lookup for this resource link.
tqc_2008 2004-09-11
  • 打赏
  • 举报
回复
up
up
up
up
up
up
up
up
up
up
up
up
up
up
up
up
up
up
up
up
up
up
up
up
up
tqc_2008 2004-09-11
  • 打赏
  • 举报
回复
up
tqc_2008 2004-09-11
  • 打赏
  • 举报
回复
up
daozi1123 2004-09-11
  • 打赏
  • 举报
回复
没有控制面版
daozi1123 2004-09-11
  • 打赏
  • 举报
回复
没错不管用
ykzhujiang 2004-09-11
  • 打赏
  • 举报
回复
控制面板里面设置了没有?
yukikaze 2004-09-11
  • 打赏
  • 举报
回复
你检查一下是不是MySql Driver 的类名写错了?
你打开你下载的MySqlDriver.jar 看看
tong82865 2004-09-11
  • 打赏
  • 举报
回复
up
tong82865 2004-09-11
  • 打赏
  • 举报
回复
up
tong82865 2004-09-11
  • 打赏
  • 举报
回复
up
Jason_guo 2004-09-11
  • 打赏
  • 举报
回复
呵呵,越急越不行。
去洗个澡,想想有没有办法查错。
---------------------------------------------------------------
我在我做的服务器上的留言本(我设计的HTTP服务器已经支持CGI了):
http://219.137.188.12:8080/gb1/index.htm
请大家测试。

高兴中。
tqc_2008 2004-09-11
  • 打赏
  • 举报
回复
up
tqc_2008 2004-09-11
  • 打赏
  • 举报
回复
up

67,512

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧