1
이 코드의 밖으로의 context.xml을 만들려고 해요 캐스트 할 수없는 좋아 context.xml에 :데이터 소스는 com.mchange.v2.c3p0.PooledDataSource
<Resource name="jdbc/MyDBHrd"
driverClass="net.sourceforge.jtds.jdbc.Driver"
maxPoolSize="100"
minPoolSize="15"
acquireIncrement="1"
auth="Container"
maxStatements="50"
idleConnectionTestPeriod="3600"
testConnectionOnCheckin="true"
automaticTestTable="connection_test"
maxIdleTime="21600"
factory="org.apache.naming.factory.BeanFactory"
type="com.mchange.v2.c3p0.ComboPooledDataSource"
jdbcUrl="jdbc:jtds:sqlserver://192.168.114.130/MyDB"
user="sa" password="password" />
그러나이의 context.xml을 사용했을 때
InitialContext cxt = new InitialContext();
String jndiName = "java:/comp/env/jdbc/MyDBHrd";
// Look up our data source
ComboPooledDataSource dataSource = (ComboPooledDataSource) cxt.lookup(jndiName);
것은 예외 :
ClassCastException: org.apache.tomcat.dbcp.dbcp.DataSource cannot be cast to com.mchange.v2.c3p0.PooledDataSource