我的問題是mysql裏面的,同樣適用。
------------------------------------------------------------------------------------------------------------------------------------------------------------------
環境:tomcat6、jdk1.6、oracle10g、myeclipse8.6
當跑jndi項目時拋出:org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create JDBC driver of class '' for connect URL 'null'異常
解決辦法:
1、在Tomcat 6.0\lib下加入oracle驅動包ojdbc14_g-10.2.0.1.0.jar
2、在Tomcat 6.0\conf下的context.xml文件中加入(在context後面+這一段)
- <Resource
- name="jdbc/aaa_db"
- type="javax.sql.DataSource"
- username="test"
- password="123456"
- driverClassName="oracle.jdbc.driver.OracleDriver"
- maxIdle="3"
- maxWait="5000"
- url="jdbc:oracle:thin:@192.168.30.99:1521:orcl"
- maxActive="10"/>
3、檢查項目中web.xml裏面的配置是否和context.xml實例名一樣
- <resource-ref>
- <description>db connect</description>
- <res-ref-name>jdbc/aaa_db</res-ref-name>
- <res-type>javax.sql.DataSource</res-type>
- <res-auth>Container</res-auth>
- </resource-ref>