tomcat6.0資料來源配置

來源:互聯網
上載者:User

最近在研究osworkflow工作流程模型,總是莫名其妙的拋出一個異常

org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot createJDBC driver of class '' for connect URL 'null'

資料查詢後,發現是因為資料來源配置的問題。

如果資料來源配置出現問題,可能會出現這樣的幾個異常

1、org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot createJDBC driver of class '' for connect URL 'null'
2、Caused by: java.sql.SQLException: No suitabledriver
3、Name jdbc is not bound in this context

資料來源配置有兩種方案:(目前找到的)

方案一:

1. %TOMCAT_HOME%下的conf中context.xml,在其中的<Context></Context>中加入如下代碼(要根據自己的情況稍加修改):

<Resource name="jdbc/myznt"   auth="Container"           type="javax.sql.DataSource"           username="root"           password="root"           driverClassName="com.mysql.jdbc.Driver"           url="jdbc:mysql://localhost:3306/myznt"           maxActive="100"           maxIdle="30"          maxWait="5000"/>
2. 在工程應用中/WEB-INF/下的web.xml中加入如下代碼(要根據自己的情況稍加修改):
<resource-ref>   <description>MySQLDataSource</description>    <res-ref-name>jdbc/myznt</res-ref-name>    <res-type>javax.sql.DataSource</res-type>    <res-auth>Container</res-auth></resource-ref>

3. 把MYSQL資料庫連接的jar包(mysql-connector-java-5.1.12.jar)%TOMCAT_HOME%下的lib目錄下和工程中的lib目錄下。

方案二:
1. %TOMCAT_HOME%下的conf中找到server.xml,在其中的<GlobalNamingResources></GlobalNamingResources>中加入如下代碼(要根據自己的情況稍加修改):

<Resource name="jdbc/myznt"   auth="Container"           type="javax.sql.DataSource"           username="root"           password="root"           driverClassName="com.mysql.jdbc.Driver"           url="jdbc:mysql://localhost:3306/myznt"           maxActive="100"           maxIdle="30"          maxWait="5000"/>

2. %TOMCAT_HOME%下的conf中找到context.xml,在其中的<Context></Context>中加入並修改成如下代碼(要根據自己的情況稍加修改):

<Context path="/znt" debug="1"reloadable="true" docBase="E:\EclipseWorkPlace\MyZNT\WebRoot"><ResourceLink global="jdbc/myznt" name="jdbc/myznt"type="javax.sql.Datasource"/>……………………<!--此間可能有系統其它自配的內容,可不管-->

3. 在工程應用中/WEB-INF/下的web.xml中加入如下代碼(要根據自己的情況稍加修改):

<resource-ref>   <description>MySQLDataSource</description>    <res-ref-name>jdbc/myznt</res-ref-name>    <res-type>javax.sql.DataSource</res-type>    <res-auth>Container</res-auth></resource-ref>

4. 把MYSQL資料庫連接的jar包(mysql-connector-java-5.1.12.jar)%TOMCAT_HOME%下的lib目錄下和工程中的lib目錄下。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.