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

Method for realizing database dynamic switching and computer readable storage medium

A storage medium and database technology, applied in database design/maintenance, database management system, structured data retrieval, etc., can solve problems such as thread insecurity, thread non-ownership, multi-thread concurrency insecurity, etc., so that performance is not affected. , to achieve the effect of read-write separation

Inactive Publication Date: 2019-10-11
南威互联网科技集团有限公司
View PDF6 Cites 6 Cited by
  • Summary
  • Abstract
  • Description
  • Claims
  • Application Information

AI Technical Summary

Problems solved by technology

[0009] Thread copy: The reason why multi-thread concurrency is unsafe is because threads do not own resources, they share and compete for resources of the process, so threads are not safe to start concurrently, and the general solution is to use locks to ensure that one resource at a time Can only be owned by at most one thread

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
  • Method for realizing database dynamic switching and computer readable storage medium
  • Method for realizing database dynamic switching and computer readable storage medium
  • Method for realizing database dynamic switching and computer readable storage medium

Examples

Experimental program
Comparison scheme
Effect test

Embodiment Construction

[0036] Such as figure 1 As shown, the present invention relies on the annotation mechanism of SpringBoot to design a set of annotations, complete the dynamic database connection pool structure, and inject it into the Spring context. The dynamic data source determines which data source to use by obtaining the data source name of the local thread copy. At the same time, through the principle of aspect programming, the business layer uses annotations to parse out the name of the data source configured on the calling method and store it in the local thread copy.

[0037] Data source configuration: application.yml is the default configuration file of SpringBoot. We use the style of SpringBoot to configure the database architecture of Master-Slaves and support multiple Slave nodes;

[0038] Initialize the data source: According to the data source configuration items and different database addresses, different database connection pools are formed and called when needed;

[0039] Def...

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 for realizing database dynamic switching, which comprises the following steps of analyzing a data source configuration file to form a corresponding database connectionpool; defining a set of annotations of data source switching; analyzing the annotation, and placing the database name in a local thread copy; returning the database object corresponding to the database name in the thread copy to the Spring framework to realize dynamic switching of the database. The invention further provides a computer readable storage medium, high cohesion and low coupling can beachieved without other service control codes, and the performance is not affected. On the basis, database read-write separation can be realized through configuration.

Description

technical field [0001] The invention relates to a method for realizing dynamic database switching and a computer-readable storage medium. Background technique [0002] For large-scale Internet applications, the number of records in a single table of the database may reach tens of millions, and the database is faced with extremely high concurrent access. In order to meet high concurrent access and ensure high availability of the database, an effective way is to adopt a read-write separation architecture to ease the read-write pressure of a single data database; the read-write separation architecture refers to: a main database is used to write data , multiple slave databases complete the operation of reading data, and the master-slave database synchronizes data through a certain mechanism; to achieve read-write separation in a project, the database connection pool must be distinguished, which ones are read connection pools, and which ones are written Connection pool; the trad...

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 Applications(China)
IPC IPC(8): G06F16/21G06F16/25
CPCG06F16/21G06F16/25
Inventor 陈光淙涂建群
Owner 南威互联网科技集团有限公司
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