[英]JDBC DataSource
When I run the following code on one machine I get tomcat implementation of org.apache.tomcat.dbcp.dbcp.BasicDataSource
and when I run it on another machine I get apache commons implementations of org.apache.commons.dbcp.BasicDataSource
(which顯然會導致ClassCastException
)。 只是想知道為什么代碼和上下文沒有變化context.xml
會導致返回兩個不同的 DataSource 實現?
Context context = (Context) initialContext.lookup("java:/comp/env");
return (DataSource) context.lookup("jdbc/dbName");
我想你沒有在你的戰爭中包括 DBCP。 所以它使用 Tomcat 中配置的任何 DataSource。 您可能正在使用兩個不同版本的 Tomcat,或者至少它們的配置不同; 一個必須有commons-dbcp.jar,另一個必須有tomcat-dbcp.jar。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.