Looking for breakthrough ideas for innovation challenges? Try Patsnap Eureka!

A method and device for obtaining database connection

A database and connection pool technology, applied in the computer field, can solve problems such as database congestion, frequent creation and destruction of database connections, and database performance bottlenecks.

Active Publication Date: 2020-10-23
SICHUAN HONGMEI INTELLIGENT TECH CO LTD
View PDF7 Cites 0 Cited by
  • Summary
  • Abstract
  • Description
  • Claims
  • Application Information

AI Technical Summary

Problems solved by technology

When there are a large number of access requests, that is, when there are a large number of processing threads to obtain data connections, the first method will frequently create and destroy database connections, causing database congestion and performance bottlenecks in the database
Although the second method solves the problem of database congestion and performance bottlenecks in the database, multiple processing threads with the same function may obtain the same database connection from the database connection pool to add and delete data in the database. , modify, check and other operations, resulting in data confusion in the database

Method used

the structure of the environmentally friendly knitted fabric provided by the present invention; figure 2 Flow chart of the yarn wrapping machine for environmentally friendly knitted fabrics and storage devices; image 3 Is the parameter map of the yarn covering machine
View more

Image

Smart Image Click on the blue labels to locate them in the text.
Viewing Examples
Smart Image
  • A method and device for obtaining database connection
  • A method and device for obtaining database connection
  • A method and device for obtaining database connection

Examples

Experimental program
Comparison scheme
Effect test

Embodiment Construction

[0063] In order to make the purpose, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments It is a part of the embodiments of the present invention, but not all of them. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative work belong to the protection of the present invention. scope.

[0064] Such as figure 1 As shown, the embodiment of the present invention provides a method for obtaining a database connection, and the method may include the following steps:

[0065] Step 101: storing a set number of database connections in a database connection pool;

[0066] Step 102: when at least one thread construction is detected, a correspon...

the structure of the environmentally friendly knitted fabric provided by the present invention; figure 2 Flow chart of the yarn wrapping machine for environmentally friendly knitted fabrics and storage devices; image 3 Is the parameter map of the yarn covering machine
Login to View More

PUM

No PUM Login to View More

Abstract

The invention provides a method and a device for obtaining a database connection, which stores a set number of database connections in a database connection pool, and creates a corresponding ThreadLocal object for each thread. When the thread receives the service request, whether the database connection is stored in the ThreadLocal object corresponding to the thread is detected, and if so, the database connection stored in the ThreadLocal object is obtained; otherwise, a database connection stored in the database connection pool is dumped into the ThreadLocal object; when the thread termination service is detected, the database connection stored by the ThreadLocal object corresponding to the thread is returned to the database connection pool and the ThreadLocal object is released. The scheme provided by the invention avoids multiple processing threads from acquiring the same database connection, thereby reducing the risk of data confusion in the database.

Description

technical field [0001] The invention relates to the field of computer technology, in particular to a method and device for acquiring database connections. Background technique [0002] For javaweb applications, when an access request is initiated through the client or terminal browser, the server-side container (tomcat) parses the received access request, and sends the parsed access request to the corresponding connector / connection interface (servlet ), that is, the server creates a processing thread for access requests, and the processing thread obtains a database connection to perform operations such as adding, deleting, modifying, and checking data in the database. [0003] At present, there are mainly two ways to obtain database connections. The first is to create a database connection for the processing thread after the processing thread is created. The second is to store a certain number of database connections in the database connection pool, and the processing thread...

Claims

the structure of the environmentally friendly knitted fabric provided by the present invention; figure 2 Flow chart of the yarn wrapping machine for environmentally friendly knitted fabrics and storage devices; image 3 Is the parameter map of the yarn covering machine
Login to View More

Application Information

Patent Timeline
no application Login to View More
Patent Type & Authority Patents(China)
IPC IPC(8): G06F16/2457
Inventor 康添
Owner SICHUAN HONGMEI INTELLIGENT TECH CO LTD
Who we serve
  • R&D Engineer
  • R&D Manager
  • IP Professional
Why Patsnap Eureka
  • Industry Leading Data Capabilities
  • Powerful AI technology
  • Patent DNA Extraction
Social media
Patsnap Eureka Blog
Learn More
PatSnap group products