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 FixesDBUTILS-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);
JavaDoc:http://tool.oschina.net/apidocs/apidoc?api=commons-dbutils
本站对 dbutils 做了一个改进,下载地址:http://www.oschina.net/uploads/app/commons-dbutils-1.1.fixed.jar 主要解决了dbutils无法处理类似 SELECT userid AS id FROM osc_users 诸如此类的问题,因为 dbutils 使用的方法是 getColumnName 而不是 getColumnLabel (此问题已经在官方的1.3版本中得以解决)。 |