簡化JDBC操作的框架,Commons DbUtils 1.6 發布
Common Dbutils是操作數據庫的組件,對傳統操作數據庫的類進行二次封裝,可以把結果集轉化成List。
DBUtils包括3個包:
org.apache.commons.dbutils
org.apache.commons.dbutils.handlers
org.apache.commons.dbutils.wrappers
DBUtils封裝了對JDBC的操作,簡化了JDBC操作,可以少寫代碼。
// Create a ResultSetHandler implementation to convert the
// first row into an Object[].
ResultSetHandler<Object[]> h = new ResultSetHandler<Object[]>() {
public Object[] handle(ResultSet rs) throws SQLException {
if (!rs.next()) {
return null;
}
ResultSetMetaData meta = rs.getMetaData();
int cols = meta.getColumnCount();
Object[] result = new Object[cols];
for (int i = 0; i < cols; i++) {
result[i] = rs.getObject(i + 1);
}
return result;
}
};
// Create a QueryRunner that will use connections from
// the given DataSource
QueryRunner run = new QueryRunner(dataSource);
// Execute the query and get the results back from the handler
Object[] result = run.query(
"SELECT * FROM Person WHERE name=?", h, "John Doe");</pre>
2014-07-20發布了1.6版本,這個版本主要是Bug修復和Insert方法添加。詳細如下:
類型 |
<th>變化</th>
<th>By</th>
</tr>
<tr class="b">
<td><img src="https://simg.open-open.com/show/e50f302b1fd671bfa207a736f0405f17.gif" alt="簡化JDBC操作的框架,Commons DbUtils 1.6 發布" title="fix" height="20" width="20" /></td>
<td>ArrayHandler應該返回一個空數組,當手柄沒有數據行時。 Fixes <a class="externalLink" href="/misc/goto?guid=4958837537969965027">DBUTILS-110</a>.</td>
<td><a href="/misc/goto?guid=4958837538068930523">britter</a></td>
</tr>
<tr class="a">
<td><img src="https://simg.open-open.com/show/e50f302b1fd671bfa207a736f0405f17.gif" alt="簡化JDBC操作的框架,Commons DbUtils 1.6 發布" title="fix" height="20" width="20" /></td>
<td>Order of columns not retained in BasicRowProcessor with HashMap Fixes <a class="externalLink" href="/misc/goto?guid=4958837538157255970">DBUTILS-114</a>. Thanks to Michael Osipov.</td>
<td><a href="/misc/goto?guid=4958837538068930523">britter</a></td>
</tr>
<tr class="b">
<td><img src="https://simg.open-open.com/show/e50f302b1fd671bfa207a736f0405f17.gif" alt="簡化JDBC操作的框架,Commons DbUtils 1.6 發布" title="fix" height="20" width="20" /></td>
<td>BeanProcessor not returning nanoseconds Fixes <a class="externalLink" href="/misc/goto?guid=4958837538256453408">DBUTILS-118</a>. Thanks to Feysal Rujbally, Daniele Cremonini.</td>
<td><a href="/misc/goto?guid=4958837538068930523">britter</a></td>
</tr>
<tr class="a">
<td><img src="https://simg.open-open.com/show/08849c607ffcac073d4d6c64dfe769cc.gif" alt="簡化JDBC操作的框架,Commons DbUtils 1.6 發布" title="add" height="20" width="20" /></td>
<td>Add support for conversion of ResultSet strings to enums in the BeanProcessor Fixes <a class="externalLink" href="/misc/goto?guid=4958837538374950907">DBUTILS-113</a>. Thanks to Graylin Kim, Michael Osipov.</td>
<td><a href="/misc/goto?guid=4958837538068930523">britter</a></td>
</tr>
<tr class="b">
<td><img src="https://simg.open-open.com/show/f9bea46c7bd98b712c93d8347683d336.gif" alt="簡化JDBC操作的框架,Commons DbUtils 1.6 發布" title="update" height="20" width="20" /></td>
<td>In BeanProcessor#isCompatibleType, can Integer.class.isInstance(value) be replaced by value instanceof Integer (etc)? Simplified code by using instanceof. Fixes <a class="externalLink" href="/misc/goto?guid=4958837538476167434">DBUTILS-85</a>.</td>
<td><a href="/misc/goto?guid=4958837538572061915">sebb</a></td>
</tr>
<tr class="a">
<td><img src="https://simg.open-open.com/show/e50f302b1fd671bfa207a736f0405f17.gif" alt="簡化JDBC操作的框架,Commons DbUtils 1.6 發布" title="fix" height="20" width="20" /></td>
<td>DBUtils can't build using JDK 1.7 - DriverProxy needs to implement getParentLogger() Add dynamic invocation. Fixes <a class="externalLink" href="/misc/goto?guid=4958837538661206938">DBUTILS-106</a>. Thanks to Niall Pemberton.</td>
<td><a href="/misc/goto?guid=4958837538572061915">sebb</a></td>
</tr>
<tr class="b">
<td><img src="https://simg.open-open.com/show/08849c607ffcac073d4d6c64dfe769cc.gif" alt="簡化JDBC操作的框架,Commons DbUtils 1.6 發布" title="add" height="20" width="20" /></td>
<td>Create functionality to return auto-generated keys in batches of SQL inserts Fixes <a class="externalLink" href="/misc/goto?guid=4958837538757018319">DBUTILS-108</a>. Thanks to Micah Huff.</td>
<td><a href="/misc/goto?guid=4958837538845102549">wspeirs</a></td>
</tr>
<tr class="a">
<td><img src="https://simg.open-open.com/show/08849c607ffcac073d4d6c64dfe769cc.gif" alt="簡化JDBC操作的框架,Commons DbUtils 1.6 發布" title="add" height="20" width="20" /></td>
<td>Patch QueryLoader to also load from XML properties files Fixes <a class="externalLink" href="/misc/goto?guid=4958837538934885737">DBUTILS-107</a>. Thanks to PB.</td>
<td><a href="/misc/goto?guid=4958837538845102549">wspeirs</a></td>
</tr>
<tr class="b">
<td><img src="https://simg.open-open.com/show/e50f302b1fd671bfa207a736f0405f17.gif" alt="簡化JDBC操作的框架,Commons DbUtils 1.6 發布" title="fix" height="20" width="20" /></td>
<td>Updated the use of getColumnName to try getColumnLabel first Fixes <a class="externalLink" href="/misc/goto?guid=4958837539036013225">DBUTILS-100</a>. Thanks to xiaofei.xu.</td>
<td><a href="/misc/goto?guid=4958837538845102549">wspeirs</a></td>
</tr>
<tr class="a">
<td><img src="https://simg.open-open.com/show/08849c607ffcac073d4d6c64dfe769cc.gif" alt="簡化JDBC操作的框架,Commons DbUtils 1.6 發布" title="add" height="20" width="20" /></td>
<td>Add missing JavaDoc to QueryRunner#insert Fixes <a class="externalLink" href="/misc/goto?guid=4958837539128419662">DBUTILS-98</a>. Thanks to Moandji Ezana.</td>
<td><a href="/misc/goto?guid=4958837539221053017">simonetripodi</a></td>
</tr>
<tr class="b">
<td><img src="https://simg.open-open.com/show/08849c607ffcac073d4d6c64dfe769cc.gif" alt="簡化JDBC操作的框架,Commons DbUtils 1.6 發布" title="add" height="20" width="20" /></td>
<td>Add an Abstract ResultSetHandler implementation in order to reduce redundant 'resultSet' variable invocation Fixes <a class="externalLink" href="/misc/goto?guid=4958837539312077682">DBUTILS-97</a>.</td>
<td><a href="/misc/goto?guid=4958837539221053017">simonetripodi</a></td>
</tr>
<tr class="a">
<td><img src="https://simg.open-open.com/show/e50f302b1fd671bfa207a736f0405f17.gif" alt="簡化JDBC操作的框架,Commons DbUtils 1.6 發布" title="fix" height="20" width="20" /></td>
<td>DbUtils#loadDriver(ClassLoader,String) makes DriverManager throwing "No suitable driver found for jdbc" if ClassLoader is not the System's one Fixes <a class="externalLink" href="/misc/goto?guid=4958837539413606845">DBUTILS-96</a>. Thanks to yuyf.</td>
<td><a href="/misc/goto?guid=4958837539221053017">simonetripodi</a></td>
</tr>
<tr class="b">
<td><img src="https://simg.open-open.com/show/08849c607ffcac073d4d6c64dfe769cc.gif" alt="簡化JDBC操作的框架,Commons DbUtils 1.6 發布" title="add" height="20" width="20" /></td>
<td>Added insert methods to QueryRunner and AsyncQueryRunner that return the generated key. Fixes <a class="externalLink" href="/misc/goto?guid=4958837539510341341">DBUTILS-87</a>. Thanks to Moandji Ezana.</td>
<td><a href="/misc/goto?guid=4958837538845102549">wspeirs</a></td>
</tr>
</tbody>
</table>
項目主頁:http://commons.apache.org/proper/commons-dbutils/
本文由用戶
jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!
sesese色