描述:
travel 這裏是數據庫名稱
沒有在Context裏面綁定jdbc/travel。
解決方案:
在Context里加入
<Resource auth="Container" driverClassName="com.mysql.jdbc.Driver"
name="jdbc/travel"
type="javax.sql.DataSource"
url="jdbc:mysql://localhost:3306/travel?characterEncoding=utf-8"
username="root"
password="pwd"
maxActive="200"
maxIdle="50"
maxWait="3000"
/>
然後在項目工程的web.xml裏面加入依賴:
<resource-ref>
<description>jdbc/travel</description>
<res-ref-name>jdbc/travel</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
錯誤修正了。