日期:2014-05-16  浏览次数:20444 次

第十七天dbutils的使用------Commons DbUtils(Apache)第三方的:只是对JDBC编码进行了简单的封装


这篇文章和前一篇的文章--------->第十七天3月12日之一句代码实现crud操作(手动写的,没使用其他jar包和框架)

所实现的功能差不多。这是第三方开发的,要导入相应的jar包(就一个jar包),比自己写的强大。强大之处在于结果集的处理。主要涉及的类是

org.apache.commons.dbutils
Class QueryRunner


API如下:

Constructor Summary
QueryRunner()
          Constructor for QueryRunner.
QueryRunner(boolean pmdKnownBroken)
          Constructor for QueryRunner, allows workaround for Oracle drivers
QueryRunner(DataSource ds)
          Constructor for QueryRunner which takes a DataSource.
QueryRunner(DataSource ds, boolean pmdKnownBroken)
          Constructor for QueryRunner, allows workaround for Oracle drivers.

 

Method Summary
 int[] batch(Connection conn, String sql, Object[][] params)
          Execute a batch of SQL INSERT, UPDATE, or DELETE queries.
 int[] batch(String sql, Object[][] params)
          Execute a batch of SQL INSERT, UPDATE, or DELETE queries.
<T> T
query(Connection conn, String sql, Object[] params, ResultSetHandler<T> rsh)
          Deprecated. Use query(Connection,String,ResultSetHandler,Object...) instead
<T> T
query(Connection conn, String sql, Object param, ResultSetHandler<T> rsh)
          Deprecated. Use