java.lang.ClassCastException: org.apache.tomcat.dbcp.dbcp.BasicDataSource cannot be cast to sun.jdbc.odbc.ee.DataSource
com.v512.chapter5.GetAddMessage.doGet(GetAddMessage.java:41)
javax.servlet.http.HttpServlet.service(HttpServlet.java:627)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
com.v512.chapter5.GetAddMessage.doGet(GetAddMessage.java:41)
javax.servlet.http.HttpServlet.service(HttpServlet.java:627)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
注意下datasouce的不同
我怀疑引用了sun的
java.sql.*
javax.sql.DataSource
javax.naming.*
使用连接池:
Context context = new InitialContext();
DataSource ds =(DataSource) context.lookup("java:/comp/env/jdbc/oracleds"); META-INF\context.xml配置:
<Resource name="jdbc/oracleds" scope="Shareable"
type="javax.sql.DataSource"
url="jdbc:oracle:thin:@157.55.55.5:1521:ORCL"
driverClassName="oracle.jdbc.OracleDriver"
username="system" password="rrrrr"
maxActive="30" maxIdle="10" maxWait="10000"
removeAbandoned="true" removeAbandonedTimeout="30" logAbandoned="true"
/>