本帖最后由 i46614161 于 2009-12-18 23:57:44 编辑

解决方案 »

  1.   

    不是不能这么调用。Statement 只是个接口,而你在getConnection里面,用了Class.forName,找到了Oracle驱动以后,对应的Statement接口具体是由Oracle jdbc实现的,在oracle中,名为OracleStatement,而OracleStatement并没有实现Statement中定义的isClosed方法,因此你这里报AbstractMethodError错误。具体的OracleStatement的属性、方法参见oracle官方jdbc包:
    http://www.oracle.com/technology/docs/tech/java/sqlj_jdbc/doc_library/javadoc/oracle.jdbc.driver.OracleStatement.html#_top_
    那么,你要检测对应的Statement是否关闭,怎么做呢?很简单,取Statement的时候,强制转换为OracleStatement,然后看它的一个public field:closed就可以。代码如下:
    OracleStatement sta = (OracleStatement) conn.createStatement();
    ResultSet rs = sta.executeQuery(sql);
    boolean a =sta.closed;
    System.out.println(a);具体Oracle jdbc都实现了些什么,请看我上面提供的链接。