最近在研究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目錄下。