I. Dbutils Core API
1. Queryrunner
Update method
Query method
2. All kinds of handler implement Resultsethandler interface
Beanhandler
Beanlisthandler
Beanmaphandler
Arrayhandler
Arraylisthandler
Maplisthandler
Scalarhandler
Columnlisthandler
Keyedhandler
Two. Handler hierarchy
Generating class diagrams using idea
Three. Queryrunner Query for Entities
Dbutils principle: Perform sql-> return resultset-> reflection Create entity Object->handler
Benefit: No need to face pstmt and RS objects
Four. Using threadlocal to achieve con transparency
Threadlocal is a container for isolating threads
Specific operation:
1) When you get con, look in the TL container
2) When the con is created, it is stored in the TL container
3) After the con is used, remove from the TL container and the TL container will be destroyed when the thread ends.
Five. Using connection pooling
Frequent creation of con objects results in significant overhead and a limited number of connections to the database, which can be pooled using the DPCP connection pool
Six. A picture to understand Maplisthandler
Report:
Add DPCP dependency in Pom.xml
1 <Dependency>2 <groupId>Org.apache.commons</groupId>3 <Artifactid>Commons-dbcp2</Artifactid>4 <version>2.0.1</version>5 </Dependency>
Pom.xml adding dbutils dependencies
1 <Dependency>2 <groupId>Commons-beanutils</groupId>3 <Artifactid>Commons-beanutils</Artifactid>4 <version>1.6</version>5 </Dependency>
Dbutils Essentials Summary