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)

解决方案 »

  1.   

    估计强转的时候出问题了,
    注意下datasouce的不同
      

  2.   

    Context context= new InitialContext(); DataSource ds= (DataSource) context.lookup("java:comp/env/jdbc/oracleds");
      

  3.   

    看下DataSource import的是哪个包下在datasource
    我怀疑引用了sun的
      

  4.   

    注意引用的几个包文件如下:
    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"
    />