`

org.apache.commons.dbcp.SQLNestedException: Cannot create JDBC driver of class '

    博客分类:
  • Java
阅读更多
org.apache.commons.dbcp.SQLNestedException: Cannot create JDBC driver of class '' for connect URL 'null'

错误代码:

    org.apache.commons.dbcp.SQLNestedException: Cannot create JDBC driver of class '' for connect URL 'null'.

错误原因:

    由于程序在执行时不能创建连接池.

解决方法

    1.在Tomcat 5.0.30中

            打开tomcat/conf/server.xml,找到<Host>,并在<Host></Host>中写入:

            <Context path="/myapp" reloadable="true" docBase="G:\\JAVAFile\\myapp\\context" >

    <!--Loader className="org.apache.catalina.loader.DevLoader" reloadable="true" debug="1"/-->

    

  <Resource name="jdbc/appfuse" auth="Container"

  type="javax.sql.DataSource"/>

 

  <ResourceParams name="jdbc/appfuse">

  <parameter>

  <name>factory</name>

  <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>

  </parameter>

  <parameter>

  <name>driverClassName</name>

  <value>org.gjt.mm.mysql.Driver</value>

  </parameter>

  <parameter>

  <name>url</name>

  <value>jdbc:mysql://localhost:3306/appfuse</value>

  </parameter>

  <parameter>

  <name>username</name>

  <value>root</value>

  </parameter>

  <parameter>

  <name>password</name>

  <value></value>

  </parameter>

  <parameter>

  <name>maxActive</name>

  <value>20</value>

  </parameter>

  <parameter>

  <name>maxIdle</name>

  <value>10</value>

  </parameter>

  <parameter>

  <name>maxWait</name>

  <value>-1</value>

  </parameter>

  </ResourceParams>

</Context>

这样就可以了.

2.在Tomcat5.5.9中

    同样在<Host></Host>中写入:

<Context path="/myapp" docBase="G:\\JAVAFile\\myapp\\context"  swallowOutput="true" crossContext="true"                   reloadable="false">

          <Logger className="org.apache.catalina.logger.FileLogger"

                   prefix="myapp." suffix=".log" timestamp="true"/>

          <Resource name="jdbc/appfuse" auth="Container" type="javax.sql.DataSource"

            username="test"

            password="test"

            driverClassName="com.mysql.jdbc.Driver"

            url="jdbc:mysql://localhost:3306/appfuse?autoReconnect=true"

            maxActive="30"

            maxIdle="5"

            maxWait="50"

            minEvictableIdleTimeMillis="4000"

            timeBetweenEvictionRunsMillis="5000"

            />

         </Context>

就能够解决问题了.
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics