1. 程式人生 > >TOMCAT 資料來源配置不同版本有不同配置法

TOMCAT 資料來源配置不同版本有不同配置法

Could not get JDBC Connection;  nested exception is  org.apache.tomcat.dbcp.dbcp.SQLNestedException: 

在將系統遷移時,發現報這個錯,後來發現是TOMCAT資料來源配置錯,因為我的這個TOMCAT6.0和之前開發的6.0不是同一個版本,所以配置有所誤差,導致得不到資料來源。

目前瞭解有兩種配置方法

第一種

                               <Resource name="資料來源名"
                   auth="Container" 
   type="javax.sql.DataSource" 
   username="資料庫登入使用者"
   password="資料庫登入使用者密碼" 
   driverClassName="oracle.jdbc.driver.OracleDriver" 
   url="jdbc:oracle:thin:@127.0.0.1:1521:oradb"
   maxActive="128" maxIdle="5" maxWait="10000"
   removeAbandoned="true"
   removeAbandonedTimeout="60" 
   logAbandoned="true"
   validationQuery="select * from dual"
   testOnBorrow="true"
   testOnReturn="true" />

第二種

                                          <Resource name="資料來源名"
auth="Container"
type="javax.sql.DataSource"
                                                url="jdbc:oracle:thin:@127.0.0.1:1521:oradb"
username="資料庫登入使用者"
password="資料庫登入使用者密碼" 
maxActive="128"
maxIdle="5"
maxWait="10000"
removeAbandoned="true"
removeAbandonedTimeout="60"
logAbandoned="true"
validationQuery="select * from dual"
testOnBorrow="true"
testOnReturn="true"/>

這兩個關鍵在第一個要設定driverClassName="oracle.jdbc.driver.OracleDriver"  第二個不需要