语句:
Connection proxyConn = (Connection)Proxy.newProxyInstance(conn.getClass().getClassLoader(),conn.getClass().getInterfaces(),this);说明下哦,变量类型:conn -- java.sql.Connection 
                this -- 本类实现了InvocationHandler接口
错误提示:
java.lang.ClassCastException
at DB.ConnectionHandler.bind(ConnectionHandler.java:16)如果我用Object o = Proxy.newProxyInstance(conn.getClass().getClassLoader(),conn.getClass().getInterfaces(),this);
打出变量o的地址 显示的是:com.microsoft.jdbc.sqlserver.SQLServerConnection@665753
那么证明 是SQLServerConnection的实例啊,难道不能转型Connection?help me!

解决方案 »

  1.   

    o instanceof Connection
    不是Connection的实例
    sql版本:8.00.760(sp3) 
      

  2.   

    问题已经解决:
    把conn.getClass().getInterfaces()替换成interfaces,并在中间加上以下代码
    Class[] interfaces =conn.getClass().getInterfaces();
    if(interfaces==null||interfaces.length==0)
    {
            interfaces = new Class[1];
            interfaces[0] = Connection.class;
    }原因是:interfaces.length==0
    就是说Connection是顶层接口