Welcome to EverybodyWiki 😃 ! Nuvola apps kgpg.png Log 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

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
    Operating systemCross-platform
    LicenseApache License 2.0
    Websitecommons.apache.org/proper/commons-dbutils/changes-report.html

    Amazon.com Logo.png Search Apache Commons DbUtils on Amazon.

    Advantages[edit]

    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]

    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]

    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]


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

    Other articles of the topic Java (programming language) : UJVM, GWT Highcharts

    Other articles of the topic Free and open-source software : Minetest, PLIB, GWT Highcharts, Blob Wars (series), Shampoo (software), CoinM, AdoptOpenJDK
    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]

    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. Search this book on Amazon.com Logo.png
    7. Parsian, Mahmoud (2006-11-08). JDBC Recipes: A Problem-Solution Approach. Apress. p. 598. ISBN 9781430200611. Search this book on Amazon.com Logo.png
    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. Search this book on Amazon.com Logo.png
    9. "DbUtils – JDBC Utility Component -- Examples". commons.apache.org. Retrieved 2019-08-18.

    External links[edit]


    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.