CN102243651B - Database connection control management method and device - Google Patents

Database connection control management method and device Download PDF

Info

Publication number
CN102243651B
CN102243651B CN201110161286A CN201110161286A CN102243651B CN 102243651 B CN102243651 B CN 102243651B CN 201110161286 A CN201110161286 A CN 201110161286A CN 201110161286 A CN201110161286 A CN 201110161286A CN 102243651 B CN102243651 B CN 102243651B
Authority
CN
China
Prior art keywords
database
connection
storehouse
connects
open mode
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Expired - Fee Related
Application number
CN201110161286A
Other languages
Chinese (zh)
Other versions
CN102243651A (en
Inventor
胡加明
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Codyy Education Technology Co Ltd
Original Assignee
Suzhou Codyy Network Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Suzhou Codyy Network Technology Co Ltd filed Critical Suzhou Codyy Network Technology Co Ltd
Priority to CN201110161286A priority Critical patent/CN102243651B/en
Publication of CN102243651A publication Critical patent/CN102243651A/en
Application granted granted Critical
Publication of CN102243651B publication Critical patent/CN102243651B/en
Expired - Fee Related legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Abstract

The invention provides a database connection control management method and device. The method comprises the following steps of: receiving a database operation request by a database execution process from a database dispatcher process; judging the type of the database operation request by the database execution process; calling a corresponding number of connections by a control process according to the type of the database operation request and a calling strategy so as to execute the database operation request; after the connections execute the database operation request, placing the connections in an open state back to a database connection stack by the database execution process for next calling; and closing the corresponding number of connections in the open state in the database connection stack by the control process according to a closing strategy.

Description

A kind of database connects control and management method and device
Technical field
The invention belongs to database access technology, relate in particular to a kind of database and connect control and management method and device.
Background technology
Nowadays, extensive application needs accessing database to obtain needed data.General in the application of database, use connect carry out and database between mutual.In actual conditions, application request all will be set up a database connection each time.Specific practice is following: at first, set up database and connect; Secondly, opening database connects; Once more, utilization should connect the execution SQL statement; At last, closing database connects, release data storehouse connection resource.
Yet there is following defective in above-mentioned way: when operated as the mass data storehouse (1), the connection of the mass data storehouse of foundation can not get timely release, caused internal memory to rise, and can make program crashing when serious; (2) set up database and connect after, need open connection, open and connect consuming time longlyer, when the concurrent operations of mass data storehouse, can cause database to carry out efficient and decline to a great extent; (3) open database and connect after, execute SQL statement and only will connect release, database connection resource does not obtain recycle, causes the efficient reduction.
Summary of the invention
The present invention provides a kind of database to connect the control and management method and installs to address the above problem.
The present invention provides a kind of database to connect the control and management method, may further comprise the steps.The database executive process receives the database manipulation request from the database dispatching process.The type of database executive process judgment data storehouse operation requests.The connection that the control process is called respective number according to the type and the regulative strategy of database manipulation request is to carry out the database operation requests.After connecting execution database operation requests, the connection that the database executive process will be in open mode is returned to database connection storehouse, supplies to call next time.The control process connects the connection that is in open mode of respective number in the storehouse according to the shutdown strategy closing database.
The present invention also provides a kind of database to connect control management device, comprises receiver module, judge module, connection management module and control module.Receiver module is used for receiving the database manipulation request from the data base call process.Judge module links to each other with receiver module, and is used for the type of judgment data storehouse operation requests.The connection management module links to each other with judge module.Control module links to each other with the connection management module, is used for the connection that type and regulative strategy according to the database manipulation request call respective number, to carry out the database operation requests.After connecting execution database operation requests; The connection management module is used for that the connection that is in open mode is returned to database and connects storehouse; Supply to call, control module connects the connection that is in open mode of respective number in the storehouse according to the shutdown strategy closing database next time.
Compared to prior art, connect control and management method and device according to database provided by the invention, controlling database according to regulative strategy and shutdown strategy through the control process connects opening of connecting in the storehouse and calls and close, thereby improves the utilization factor that connects.In addition, connect recycling of storehouse fulfillment database connection, prevent to set up the multiple database connection simultaneously and take Installed System Memory through database.And after connecting execution database operation requests, the connection that is in open mode will be returned to database and connect storehouse.So, the connection that can be recycled and opened, thus improve the service efficiency that connects.In addition, call with its corresponding database according to the type of database manipulation request and to be connected the connection in the storehouse, so, database manipulation is separated, improve database and carry out efficient.
Description of drawings
Accompanying drawing described herein is used to provide further understanding of the present invention, constitutes the application's a part, and illustrative examples of the present invention and explanation thereof are used to explain the present invention, do not constitute improper qualification of the present invention.In the accompanying drawings:
The database that provides for preferred embodiment according to the present invention shown in Figure 1 connects the process flow diagram of control and management method;
The database that provides for preferred embodiment according to the present invention shown in Figure 2 connects the process flow diagram of control and management method;
The database that provides for preferred embodiment according to the present invention shown in Figure 3 connects the synoptic diagram of control management device.
Embodiment
Hereinafter will and combine embodiment to specify the present invention with reference to accompanying drawing.Need to prove that under the situation of not conflicting, embodiment and the characteristic among the embodiment among the application can make up each other.
The database that provides for preferred embodiment according to the present invention shown in Figure 1 connects the process flow diagram of control and management method.As shown in Figure 1, the database that preferred embodiment of the present invention provides connects the control and management method and comprises step 101~105.In step 101, the database executive process receives the database data request from the database dispatching process.In step 102, the type of database executive process judgment data storehouse operation requests.In step 103, the connection that the control process is called respective number according to the type and the regulative strategy of database manipulation request is to carry out the database operation requests.In step 104, after connecting execution database operation requests, the connection that the database executive process will be in open mode is returned to database connection storehouse, supplies to call next time.In step 105, the control process connects the connection that is in open mode of respective number in the storehouse according to the shutdown strategy closing database.
Wherein, Shutdown strategy is: when the linking number of in database connects storehouse, carrying out the database operation requests is less than or equal to preset value with the ratio that is in the linking number of open mode, connect the unnecessary connection that is in open mode in the storehouse according to preset number percent closing database.Regulative strategy comprises: be less than or equal to database in the number of current database operation requests and connect and be in open mode in the storehouse but not during the number of the connection of executable operations, that calls that database connects respective number in the storehouse is in open mode but the not connection of executable operations; In the number of current database operation requests greater than database connect be in open mode in the storehouse but not the number of the connection of executable operations and be less than or equal to database connect be in open mode in the storehouse but not the number of the connection of executable operations when being in the number sum that is connected of closed condition; Call database and connect in the storehouse and be in open mode but the not connection of executable operations, and open and call the connection that is in closed condition that said database connects respective number in the storehouse; In the number of current database operation requests greater than database connect be in open mode in the storehouse but not the number of the connection of executable operations when being in the number sum that is connected of closed condition; Call in the database connection storehouse and be in open mode but the not connection of executable operations; Open and call said database and connect the connection that all is in closed condition in the storehouse; And call other databases and connect the vacant available connection in storehouses; If said vacant available connection is in closed condition, then open and call said vacant available connection.
As follows said process is elaborated.Please refer to Fig. 2.The database that provides for preferred embodiment according to the present invention shown in Figure 2 connects the process flow diagram of control and management method.As shown in Figure 2, the database that present embodiment provides connects the control and management method and comprises step 201~206.In step 201, the database dispatching process receives the database manipulation request from professional logical process.
In step 202, the database dispatching process is sent to corresponding database executive process with the mapping relations of database executive process with the database manipulation request according to the priority and the type of service of the type of service of database manipulation request.In this, the type of service of database manipulation request comprises subscriber information management, information off-line management and chat message management.Yet the present invention does not limit this.In practical application, other type of service can be set as required.
Particularly, after the database dispatching process receives the database manipulation request,, adopt the execution sequence of task queue management database operation requests according to the priority of the type of service of database manipulation request.In this, preferentially carry out type of service priority higher data storehouse operation requests.For example; The priority of subscriber information management is higher than information off-line management and chat message management, and the priority of information off-line management is higher than the chat message management, at this moment; To the operation of subscriber information management (for example; Inquiry or modification) priority processing, then, the operation of information off-line management and chat message management is carried out successively.
In addition, the database dispatching process is sent to corresponding database executive process with the mapping relations of database executive process with the database manipulation request according to type of service.For example; If about the type of service of subscriber information management corresponding to database executive process 1; About the type of service of information off-line management corresponding to database executive process 2; Corresponding to database executive process 3, in conjunction with the priority of above-mentioned type of service, then the database dispatching process preferentially is sent to database executive process 1 with the database manipulation request of relevant subscriber information management about the type of service of chat message management; The database manipulation request of successively relevant information off-line being managed then is sent to database executive process 2, and the database manipulation request that relevant chat message is managed is sent to database executive process 3.
In step 203, the type of judgment data storehouse operation requests after the request of database executive process reception database manipulation.In this, the type of database manipulation request comprises inquiry, increase, deletion and revises.Yet the present invention is not limited thereto.
Particularly, after the database executive process receives the database manipulation request, at first task queue is put in the database manipulation request that receives.Then, the database executive process is according to the database manipulation request of task queue scheduling, the type of judgment data storehouse operation requests.Yet the present invention is not limited thereto.In other embodiment, the database executive process receive after the database manipulation request can first judgment data storehouse operation requests type, then, the various tasks formation is put in the database manipulation request according to the type of database manipulation request, supply follow-up execution.
Next, be that example is elaborated with the query manipulation, the execution of other operations is identical with the execution of query manipulation, so repeat no more in this.In present embodiment, according to the type of database manipulation request, its corresponding database is at first called in different database manipulation requests connect the connection in the storehouse, to carry out said database manipulation request, carry out efficient thereby improve database.
In step 204, the connection that the control process is called respective number according to regulative strategy is to carry out the data base querying request.Wherein, regulative strategy comprises following three aspects.
Being less than or equal to data base querying in the number of current database query requests connects and is in open mode in the storehouse but not during the number of the connection of executable operations; Call interior the said of respective number of data base querying connection storehouse and be in open mode but the not connection of executable operations, to carry out the current database query requests.For example; If the current database query requests has 5; The linking number that data base querying just connects in the storehouse in executable operations is 4; It is 10 that data base querying connects the linking number of having opened in the storehouse, then calls interior 5 connections of having opened of data base querying connection storehouse and carries out the request of current 5 data library inquiries.
In the number of current database query requests greater than data base querying connect be in open mode in the storehouse but not the number of the connection of executable operations and be less than or equal to data base querying connect be in open mode in the storehouse but not the number of the connection of executable operations when being in the number sum that is connected of closed condition; Call data base querying and connect in the storehouse and be in open mode but the not connection of executable operations, and open and call the connection that is in closed condition that data base querying connects respective number in the storehouse.For example; If the current database query requests has 10; Data base querying connects the connection that is provided with in the storehouse and adds up to 20, and the linking number of having opened is 10, and just the linking number in executable operations is 4; Then call interior 6 of data base querying connection storehouse and be in open mode but the not connection of executable operations, and open and call 4 connections that are in closed condition.
In the number of current database query requests greater than data base querying connect be in open mode in the storehouse but not the number of the connection of executable operations when being in the number sum that closed condition is connected; Call in the data base querying connection storehouse and be in open mode but the not connection of executable operations; Open and call data base querying and connect the connection that all is in closed condition in the storehouse; And (for example call other databases connection storehouses; Database is deleted and is connected storehouse, database update connection storehouse, database increase connection storehouse) interior vacant available connection, if said vacant available connection is in closed condition, then open and call said vacant available connection.For example; If the current database query requests has 10, data base querying connects the connection that is provided with in the storehouse and adds up to 20, and the linking number of having opened is 18; Just the linking number in executable operations is 15; Then call interior 3 of data base querying connection storehouse and be in open mode but the not connection of executable operations, open and call 2 connections that are in closed condition, and call 5 vacant available connections in the database update connection storehouse.
The process that connects the vacant available connection in the storehouse about other databases of control process transfer is that example is explained as follows with database update connection storehouse.Control process lock database is revised and is connected storehouse, and calls the vacant available connection that database update connects respective number in the storehouse.Remove the locking of database update connection storehouse in the control process after, the data base querying request of respective number is carried out in above-mentioned vacant available connection.Wherein, if above-mentioned vacant available connection is in open mode, then directly calls above-mentioned vacant available connection and carry out the data base querying request; If above-mentioned vacant available connection is in closed condition, then need opens above-mentioned connection earlier and carry out the data base querying request again.
In step 205, after connecting the request of execution data base querying, the connection that the database executive process will be in open mode is returned to database connection storehouse, supplies to call next time.In this, when the connection when the data base querying request connects storehouse by data base querying in was carried out, will the be finished connection that is in open mode of database executive process all was returned to data base querying and connects storehouse.When the data base querying request was connected storehouse and database update and connects connection in the storehouse and carry out jointly by data base querying, the connection that the database executive process can be in open mode with being finished was returned in data base querying connects storehouse or data base querying connects storehouse and database update is connected storehouse.Yet the present invention does not limit this.Wherein it should be noted that; When the database executive process will be finished the connection that is in open mode when being returned to database update and connecting storehouse; Need first lock database to revise and connect storehouse, and after putting back to connection, remove the locking that database update is connected storehouse.
So, the connection that database connects in the storehouse can be recycled, thereby increases operation rate.And in a single day connection is in open mode after being opened always, opens the spent time thereby saved dramatically to connect, and has improved the execution efficient of database.
In step 206, the control process is according to the connection that is in open mode of respective number in the shutdown strategy closing database inquiry connection storehouse.Wherein, shutdown strategy specifically describes as follows.The linking number of in data base querying connects storehouse, carrying out the database operation requests (for example is less than or equal to preset value with the ratio that is in the linking number of open mode; 70%) time; Number percent (for example, 80%) closing database inquiry according to preset connects the unnecessary connection that is in open mode in the storehouse.The number of the connection that is in open mode that wherein, need close equal to be in open mode connection number with just at the difference of the number that is connected of executable operations product with preset number percent.For example; If it is 60 that data base querying connects the linking number of carrying out the database operation requests in the storehouse; It is 100 that data base querying connects the linking number that is in open mode in the storehouse; Both ratio then connects 32 connections that are in open mode in the storehouse according to preset number percent (80%) closing database inquiry less than preset value (70%).In practical application, if the number of the connection that is in open mode that the needs that process calculates are closed not is to be integer, the above-mentioned number that then will calculate rounds with the mode that rounds up, with the number of the definite connection that is in open mode that need close.For example; If it is 65 that data base querying connects the linking number of carrying out the database operation requests in the storehouse; It is 100 that data base querying connects the linking number that is in open mode in the storehouse; Both ratio then connects the connection that storehouse interior 26 (actual computation numerical value is 26.25, and round is 26) is in open mode according to preset number percent (75%) closing database inquiry less than preset value (70%).
In addition, in present embodiment, the control process is opened to call and can be real-time control what connect, the closing control that connects can be real-time control also can be timing controlled.For example, control process whenever connected the connection that is in open mode of respective number in the storehouse according to the shutdown strategy closing database at a distance from 30 minutes.Yet the present invention does not do any qualification to this.
The synoptic diagram that connects control management device for the database that preferred embodiment provides according to the present invention shown in Figure 3.As shown in Figure 3, the database that present embodiment provides connects control management device and comprises scheduler module 300, receiver module 301, judge module 302, connection management module 303 and control module 304.Wherein, scheduler module 300 links to each other with receiver module 301, and judge module 302 links to each other with receiver module 301, and connection management module 303 links to each other with judge module 302, and control module 304 links to each other with connection management module 303.Yet the present invention is not limited thereto.
In present embodiment; Scheduler module 300 is used for receiving the database manipulation request from professional logical process, and with the mapping relations of database executive process the database manipulation request is sent to corresponding receiver module 301 according to the priority and the type of service of the type of service of database manipulation request.Receiver module 301 is used for receiving the database manipulation request from scheduler module 300.Judge module 302 is used to judge the type of the database manipulation request that receives.Control module 304 is used for the connection of calling respective number according to the type of database manipulation request and regulative strategy, to carry out the database operation requests.After connecting execution database operation requests, the connection that connection management module 303 will be in open mode is returned to database connection storehouse, supplies to call next time.Control module 304 connects the connection that is in open mode of respective number in the storehouse according to the shutdown strategy closing database.Detailed process is ditto said, so repeat no more in this.
In sum; The database that preferred embodiment provides according to the present invention connects control and management method and device; Controlling database according to regulative strategy and shutdown strategy through the control process connects opening of connecting in the storehouse and calls and close, thereby improves the utilization factor that connects.In addition, connect recycling of storehouse fulfillment database connection, prevent to set up the multiple database connection simultaneously and take Installed System Memory through database.And after connecting execution database operation requests, the connection that is in open mode is returned to database and connects storehouse.So, the connection that can be recycled and opened, thus improve the service efficiency that connects.In addition, call with its corresponding database according to the type of database manipulation request and to be connected the connection in the storehouse, so, database manipulation is separated, improve database and carry out efficient.
The above is merely the preferred embodiments of the present invention, is not limited to the present invention, and for a person skilled in the art, the present invention can have various changes and variation.All within spirit of the present invention and principle, any modification of being done, be equal to replacement, improvement etc., all should be included within protection scope of the present invention.

Claims (3)

1. a database connects the control and management method, it is characterized in that, may further comprise the steps:
The database executive process receives the database manipulation request from the database dispatching process;
Said database executive process is judged the type of said database manipulation request;
The connection that the control process is called respective number according to the type and the regulative strategy of said database manipulation request, said database manipulation request is carried out in said connection;
After said database manipulation request was carried out in said connection, the connection that said database executive process will be in open mode was returned to database and connects storehouse, supplied to call next time;
Said control process is closed the connection that is in open mode that said database connects respective number in the storehouse according to shutdown strategy,
Wherein, Said regulative strategy comprises: be less than or equal to database in the number of current database operation requests and connect and be in open mode in the storehouse but not during the number of the connection of executable operations, call database and connect that the said of respective number is in open mode but the not connection of executable operations in the storehouse; In the number of current database operation requests greater than database connect be in open mode in the storehouse but not the number of the connection of executable operations and be less than or equal to database connect be in open mode in the storehouse but not the number of the connection of executable operations when being in the number sum that is connected of closed condition; Call said database and connect in the storehouse and be in open mode but the not connection of executable operations, and open and call the connection that is in closed condition that said database connects respective number in the storehouse; In the number of current database operation requests greater than database connect be in open mode in the storehouse but not the number of the connection of executable operations when being in the number sum that is connected of closed condition; Call in the said database connection storehouse and be in open mode but the not connection of executable operations; Open and call said database and connect the connection that all is in closed condition in the storehouse; And call other databases and connect the vacant available connection in storehouses; If said vacant available connection is in closed condition, then open and call said vacant available connection
Said shutdown strategy is: when the linking number of in database connects storehouse, carrying out the database operation requests is less than or equal to preset value with the ratio that is in the linking number of open mode, connect the unnecessary connection that is in open mode in the storehouse according to preset number percent closing database.
2. database according to claim 1 connects the control and management method, it is characterized in that, said database connects storehouse and comprises that data base querying connects storehouse, database increase connection storehouse, the database deletion connects storehouse and database update connects storehouse.
3. database according to claim 1 connects the control and management method, it is characterized in that, the type of said database manipulation request comprises inquiry, increase, deletion and revises.
CN201110161286A 2011-06-16 2011-06-16 Database connection control management method and device Expired - Fee Related CN102243651B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201110161286A CN102243651B (en) 2011-06-16 2011-06-16 Database connection control management method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201110161286A CN102243651B (en) 2011-06-16 2011-06-16 Database connection control management method and device

Publications (2)

Publication Number Publication Date
CN102243651A CN102243651A (en) 2011-11-16
CN102243651B true CN102243651B (en) 2012-09-26

Family

ID=44961706

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201110161286A Expired - Fee Related CN102243651B (en) 2011-06-16 2011-06-16 Database connection control management method and device

Country Status (1)

Country Link
CN (1) CN102243651B (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102708175B (en) * 2012-05-07 2014-04-30 北京航空航天大学 Automatic reconnection method and automatic reconnection device for contingency interrupt of database connection
CN103516668B (en) * 2012-06-20 2017-03-01 中国银联股份有限公司 The data processing server being reconnected based on broadcast data storehouse and broadcast data storehouse reconnection method

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1815469A (en) * 2005-02-01 2006-08-09 华为技术有限公司 Database connection resource management method
CN101408899A (en) * 2008-11-21 2009-04-15 北京中企开源信息技术有限公司 Method and apparatus for switching website multiple data sources

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20070260542A1 (en) * 2006-05-08 2007-11-08 Kinghood Technology Co., Ltd. Distributed transaction processing system and method thereof

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1815469A (en) * 2005-02-01 2006-08-09 华为技术有限公司 Database connection resource management method
CN101408899A (en) * 2008-11-21 2009-04-15 北京中企开源信息技术有限公司 Method and apparatus for switching website multiple data sources

Also Published As

Publication number Publication date
CN102243651A (en) 2011-11-16

Similar Documents

Publication Publication Date Title
CN102243597B (en) Method and device for controlling and managing database connections
CN102243653B (en) Method and device for managing database connections
CN101201753B (en) Method for configuring and managing multimode machine supervising engine
CN102243655B (en) Method and device for managing database connections
US20060206894A1 (en) Method of scheduling jobs using database management system for real-time processing
CN105069134A (en) Method for automatically collecting Oracle statistical information
US20100087941A1 (en) Method and system for managing process jobs in a semiconductor fabrication facility
CN109840144B (en) Information service scheduling method and system for cross-mechanism batch service request
CN102243652B (en) Database connection management method and device
CN103473642A (en) Method for rule engine for production dispatching
CN101686488A (en) Service processing method, processing system and work sheet processing device
CN102243654B (en) Method and device for controlling and managing database connections
CN102243651B (en) Database connection control management method and device
CN105893320A (en) Remote task function calling method oriented at multi-core processor
CN113448685A (en) Pod scheduling method and system based on Kubernetes
CN109726007A (en) A kind of container layout quota management method and device and container arranging system
CN114691340A (en) Heterogeneous multi-robot task scheduling method and system based on multistage feedback queue
CN113157297B (en) Remote upgrading method and system for charging station equipment
CN102262655B (en) Connection control method and device for database
CN112363812B (en) Database connection queue management method based on task classification and storage medium
CN105446812A (en) Multitask scheduling configuration method
CN112748997A (en) Workflow scheduling method and system
CN101754156A (en) Office data management method, device and charging system
CN106201692A (en) A kind of timing task processing system and method
CN111198915A (en) Data distribution system and method based on public information model

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
C14 Grant of patent or utility model
GR01 Patent grant
C56 Change in the name or address of the patentee
CP01 Change in the name or title of a patent holder

Address after: Suzhou City, Jiangsu province 215121 Fengting Avenue Suzhou Industrial Park No. 666 Weiting Intelligent Industrial Park Building 8

Patentee after: Kuo Di education and science company limited

Address before: Suzhou City, Jiangsu province 215121 Fengting Avenue Suzhou Industrial Park No. 666 Weiting Intelligent Industrial Park Building 8

Patentee before: Suzhou Kuodi Network Technology Co., Ltd.

CF01 Termination of patent right due to non-payment of annual fee
CF01 Termination of patent right due to non-payment of annual fee

Granted publication date: 20120926

Termination date: 20180616