Welcome to EverybodyWiki ! Nuvola apps kgpg.png Sign in or create an account to improve, watchlist or create an article like a company page or a bio (yours ?)...

Apache Commons DbUtils

From EverybodyWiki Bios & Wiki
Jump to navigation Jump to search




Apache Commons DbUtils is a library designed to facilitate easy usage of JDBC (as it is mentioned in its official website).[1][2][3][4][5][6][7][8]

Apache Commons DBUtils
Developer(s)Apache Software Foundation
Stable release
1.7 / July 2017, 20 (20-07-2017)
Repositoryhttps://github.com/apache/commons-dbutils
Written inJava
Engine
    Lua error in Module:Wd at line 162: attempt to index field 'wikibase' (a nil value).
Operating systemCross-platform
LicenseApache License 2.0
Websitecommons.apache.org/proper/commons-dbutils/changes-report.html

Advantages[edit | edit source]

Some advantages are given below (as it is mentioned in its official website):

  • Less possibility for resource leaks.
  • Cleaner, clearer persistence code.
  • Automatically populate JavaBean properties from ResultSets. [1]

Scope[edit | edit source]

DbUtils is designed to cover following scopes:

  • Small - user should be able to understand the whole package in a short amount of time.
  • Transparent - user gives it a query, it executes it and cleans up.
  • Fast - user don't need to create many temporary objects to work with DbUtils.[1]

Example[edit | edit source]

Sample code may look like as follows:

// 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");

[9]


See also[edit | edit source]


Others articles of the Topics Java (programming language) AND Free and open-source software : GWT Highcharts

Others articles of the Topic Java (programming language) : UJVM, GWT Highcharts

Others articles of the Topic Free and open-source software : Ring (programming language), Jovo Framework, Aria Maestosa, Jam.py, Gimmie, Lobsters (software), Moleculer
Some use of "" in your query was not closed by a matching "".Some use of "" in your query was not closed by a matching "".

References[edit | edit source]

  1. 1.0 1.1 1.2 "DbUtils – JDBC Utility Component". commons.apache.org. Retrieved 2019-08-18.
  2. Mirror of Apache Commons DbUtils. Contribute to apache/commons-dbutils development by creating an account on GitHub, The Apache Software Foundation, 2019-08-16, retrieved 2019-08-18
  3. baeldung (2017-07-11). "A Guide to Apache Commons DbUtils". Baeldung. Retrieved 2019-08-18.
  4. "Java Code Examples org.apache.commons.dbutils.DbUtils". www.programcreek.com. Retrieved 2019-08-18.
  5. "org.apache.commons.dbutils.DbUtils java code examples | Codota". www.codota.com. Retrieved 2019-08-18.
  6. Oak, Harshad (2008-01-01). Pro Jakarta Commons. Apress. p. 204. ISBN 9781430207177.
  7. Parsian, Mahmoud (2006-11-08). JDBC Recipes: A Problem-Solution Approach. Apress. p. 598. ISBN 9781430200611.
  8. Nurkiewicz, Tomasz; Christensen, Ben (2016-10-06). Reactive Programming with RxJava: Creating Asynchronous, Event-Based Applications. "O'Reilly Media, Inc.". p. 237. ISBN 9781491931622.
  9. "DbUtils – JDBC Utility Component -- Examples". commons.apache.org. Retrieved 2019-08-18.

External links[edit | edit source]


This article "Apache Commons DbUtils" is from Wikipedia. The list of its authors can be seen in its historical and/or the page Edithistory:Apache Commons DbUtils. Articles copied from Draft Namespace on Wikipedia could be seen on the Draft Namespace of Wikipedia and not main one.



Compte Twitter EverybodyWiki Follow us on https://twitter.com/EverybodyWiki !