Inkfish original, do not reprint commercial nature, reproduced please indicate the source (http://blog.csdn.net/inkfish).
Dbutils is a small class library, and it doesn't take long to familiarize yourself with each class. The Dbutils core actually has only three classes/interfaces, namely Queryrunner, Resultsethandler, and Dbutls (the top two are written in the official document). (Source: Http://blog.csdn.net/inkfish)
A Let's take a look at some of Dbutils's packages (package): (Source: Http://blog.csdn.net/inkfish)
1.org.apache.commons.dbutils
Provides core classes/interfaces to provide the most commonly used and most versatile features. (Source: Http://blog.csdn.net/inkfish)
2.org.apache.commons.dbutils.handlers
Provides various forms of packaging for resultset, all classes are implemented Resultsethandler, and therefore can also be seen as an extension of resultsethandler. Functions such as turning each row in the resultset into a javabean or an array. (Source: Http://blog.csdn.net/inkfish)
3.org.apache.commons.dbutils.wrappers
Provides packaging filtering for values in resultset, and all classes implement Java.lang.reflect.InvocationHandler. Functions such as trim () operations on all string values in the resultset, or assign all null values to a meaningful new value. (Source: Http://blog.csdn.net/inkfish)
Two The following is a description of the use of Dbutils: (Source: Http://blog.csdn.net/inkfish)
1.org.apache.commons.dbutils.dbutils
The Dbutils class is a tool class in which all the methods are static and therefore can be invoked without instantiation, with an introduction to the API to understand their functions: (Source: Http://blog.csdn.net/inkfish) Close: Closing connection, Statement or resultset, ignoring null; closequietly: Quiet shutdown connection, Statement, or resultset, it will try to close, ignore null and sqlexception; Commitandclose: Commit and close connection, ignore null; commitandclosequietly: Commit and close connection, ignore null and SqlException; loaddriver : The same as the Class.forName (). newinstance () feature, but it captures the exception and returns TRUE or false; Printstacktrace: Prints SqlException detailed error messages; printwarnings : Print connection warning messages; rollback: rollback operation, ignore null; Rollbackandclose: Rollback operation and Close, ignore null; rollbackandclosequietly: Rollback operation and close, ignore null , SQLException.
2.org.apache.commons.dbutils.queryrunner (Source: http://blog.csdn.net/inkfish) Batch: Performing a batch Insert , UPDATE, delete operation, fillstatement: Fills the PreparedStatement with the value of object[] or JavaBean; query: Perform a query operation (Statement or PreparedStatement) and Resultsethandler to handle the ResultSet update: the INSERT or update operation (either Statement or PreparedStatement) can be performed.
3.org.apache.commons.dbutils.resultsethandler
All Resultsethandler implementations provided in Dbutils are thread-safe arrayhandler: The first line of ResultSet is packaged into object[]; Arraylisthandler : Pack the resultset into a list<object[]>; Beanhandler: Pack resultset the first line into a javabean; Beanlisthandler: Put resultset The first line is packaged into a list<javabean>; Columnlisthandler: Extracts resultset specified columns, returns as List<object> objects, the default first column; Keyedhandler : Wrapper resultset, returned as a Map<object,map<string,object>> object, the first object is the specified column value, and String in the second MAP is the column name; Maphandler : The first line of resultset packaging into map<string, object> Maplisthandler: resultset packaging into list<map<string,object>>; Scalarhandler: Extracts resultset the first row of the specified column, which is returned as object.
4.org.apache.commons.dbutils.wrappers.sqlnullcheckedresultset
The null value in the resultset is processed.
5.org.apache.commons.dbutils.wrappers.stringtrimmedresultset
Trim () handles the string in resultset. (Source: Http://blog.csdn.net/inkfish)