请问下下面这几句代码是什么意思??PreparedStatement ps;   //1
Method executeBatch = ps.getClass().getMethod("executeBatch", new Class[]{});   //2
executeBatch.invoke(ps, (Object[])null);  //3
 
查过API第3句的
 Object invoke(Object obj, Object... args) 
          对带有指定参数的指定对象调用由此 Method 对象表示的底层方法。 这3句的意思是调用PreparedStatement 中的executeBatch方法????知道的帮忙解说下,谢谢

解决方案 »

  1.   

    你说的不对吗?是调executeBatch啊
      

  2.   

    executeBatch.invoke(ps);  //这样就可以了,无参的时候!
    就是调用方法!
      

  3.   

    这个是java反射中的基础,建议楼主看一下JDK文档。
      

  4.   

    你用过Struts之类的框架吗,假设你用过,那么,从页面传递过来的数据就是通过类反射(主要用Method)被放入ActionFrom中的,框架帮你做了,要不你得一个一个的手动把值付进去,——累。