又見Cannot create JDBC driver of class

雖然是老問題了,但是還是出現了,這個起了作用


又見Cannot create JDBC driver of class...2008年04月23日 11:38前天打開一別人寫的JSP源碼準備運行,該項目使用的是MYSQL數據庫,同樣使用了數據源,運行時出現了Cannot create JDBC driver of class '' for connect URL 'null' 錯誤,今天得以解決。

問題出現的原因在於該項目是比較舊的一個項目,使用的數據庫連接池配置也是舊版本的,在Tomcat5.5下就出現了Cannot create JDBC driver of class '' for connect URL 'null' 的錯誤了。

原數據庫連接池配置[該配置在Tomcat5.5下出Cannot create JDBC driver of class '' for connect URL 'null'錯]:

<?xml version='1.0' encoding='utf-8'?>
<Context displayName="stat" docBase="D:\eclipse_workspace\chpt4\WebRoot" path="/stat" workDir="">
<Resource auth="Container" name="jdbc/stat" type="javax.sql.DataSource"/>
<ResourceParams name="jdbc/stat">
<parameter>
<name>url</name>
<value>jdbc:mysql://localhost/stat</value>
</parameter>
<parameter>
<name>maxIdle</name>
<value>5</value>
</parameter>
<parameter>
<name>maxActive</name>
<value>50</value>
</parameter>
<parameter>
<name>maxWait</name>
<value>3000</value>
</parameter>
<parameter>
<name>driverClassName</name>
<value>org.gjt.mm.mysql.Driver</value>
</parameter>
<parameter>
<name>removeAbandoned</name>
<value>true</value>
</parameter>
<parameter>
<name>username</name>
<value>root</value>
</parameter>
<parameter>
<name>password</name>
<value>123123</value>
</parameter>
<parameter>
<name>factory</name>
<value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
</parameter>
</ResourceParams>
</Context>

應該將上面配置修改爲如下形式:

<Context displayName="stat" path="/stat" docBase="D:\eclipse_workspace\chpt4\WebRoot" workDir="">
[color=red] <Resource name="jdbc/stat" auth="Container" type="javax.sql.DataSource" driverClassName="org.gjt.mm.mysql.Driver" url="jdbc:mysql://localhost/stat" username="root" password="123123" maxActive="50" maxWait="3000" maxIdle="5" removeAbandoned="true" factory="org.apache.commons.dbcp.BasicDataSourceFactory"/>[/color]
</Context>


改好之後就不出現這個Cannot create JDBC driver of class '' for connect URL 'null' 問題了。


=============================================================
Cannot create JDBC driver of class "" for connect URL "null" 解決方案
  
  Cannot create JDBC driver of class "" for connect URL "null" 解決方案 方案(1)
  解決:在%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。
  [quote]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.[/quote]
Cannot create JDBC driver of class "" for connect URL "null" 解決方案 Cannot create JDBC driver of class "" for connect URL "null" 解決方案 方案(1)解決:在%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.
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章