发布于 2014-07-21 23:32:16 | 228 次阅读 | 评论: 0 | 来源: 网友投递

这里有新鲜出炉的精品教程,程序狗速度看过来!

Commons DbUtils开源 JDBC 工具类库

Commons DbUtils是 Apache 组织提供的一个开源 JDBC 工具类库,对传统操作数据库的类进行二次封装,可以把结果集转化成List,Map等。


Apache Commons DbUtils 1.6 发布,主要改进内容包括:

  • ArrayHandler should return an empty array when handle has no rows Fixes DBUTILS-110.

  • Order of columns not retained in BasicRowProcessor with HashMap Fixes DBUTILS-114.

  • BeanProcessor not returning nanoseconds Fixes DBUTILS-118.

  • Add support for conversion of ResultSet strings to enums in the BeanProcessor Fixes DBUTILS-113.

  • In BeanProcessor#isCompatibleType, can Integer.class.isInstance(value) be replaced by value instanceof Integer (etc)?        Simplified code by using instanceof. Fixes DBUTILS-85.

  • DBUtils can't build using JDK 1.7 - DriverProxy needs to implement getParentLogger()        Add dynamic invocation. Fixes DBUTILS-106.

  • Create functionality to return auto-generated keys in batches of SQL inserts Fixes DBUTILS-108.

  • Patch QueryLoader to also load from XML properties files Fixes DBUTILS-107.

  • Updated the use of getColumnName to try getColumnLabel first Fixes DBUTILS-100.

  • Add missing JavaDoc to QueryRunner#insert Fixes DBUTILS-98.

  • Add an Abstract ResultSetHandler implementation in order to reduce redundant 'resultSet' variable invocation Fixes DBUTILS-97.

  • DbUtils#loadDriver(ClassLoader,String) makes DriverManager throwing "No suitable driver found for jdbc"        if ClassLoader is not the System's one Fixes DBUTILS-96.

  • Added insert methods to QueryRunner and AsyncQueryRunner that return the generated key. Fixes DBUTILS-87.

此版本源代码和二进制包都已提供下载

Maven:
  <groupId>commons-dbutils</groupId>
  <artifactId>commons-dbutils</artifactId>
  <version>1.6</version>

更多更新内容请看发行说明

原则上这不能说是一个持久层框架,它提供了一些Jdbc的操作封装来简化数据查询和记录读取操作。本站就是采用这个项目来读写数据库,代码非常简洁,如果你厌烦了Hibernate的庞大,不妨可以试试——DbUtils。

给出一小段代码看看DbUtils是怎么用的:

QueryRunner run = new QueryRunner(dataSource); // Use the BeanHandler implementation to convert the first
// ResultSet row into a Person JavaBean. ResultSetHandler h = new BeanHandler(Person.class); // Execute the SQL statement with one replacement parameter and
// return the results in a new Person object generated by the BeanHandler. Person p = (Person) run.query("SELECT * FROM Person WHERE name=?", "John Doe", h);


历史版本 :
Apache Commons DbUtils 1.6 发布
最新网友评论  共有(0)条评论 发布评论 返回顶部

Copyright © 2007-2017 PHPERZ.COM All Rights Reserved   冀ICP备14009818号  版权声明  广告服务