Dbutils Essentials Summary

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.