开发者

JDBC DataSource

开发者 https://www.devze.com 2023-03-01 12:55 出处:网络
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

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 obviously results in ClassCastException). Just wondering why no change in code and context.xml would result in returning two different implementations of DataSource?

Context context = (Context) initialContext.开发者_开发知识库lookup("java:/comp/env");
return (DataSource) context.lookup("jdbc/dbName");


I suppose you are not including DBCP inside your war. So it's using whatever DataSource is configured in Tomcat. You're probably using two different versions of Tomcat, or at least they have been configured differently; one must have commons-dbcp.jar and the other one has tomcat-dbcp.jar.

0

精彩评论

暂无评论...
验证码 换一张
取 消