CN104281587B - A kind of method and device for establishing connection - Google Patents

A kind of method and device for establishing connection Download PDF

Info

Publication number
CN104281587B
CN104281587B CN201310277055.2A CN201310277055A CN104281587B CN 104281587 B CN104281587 B CN 104281587B CN 201310277055 A CN201310277055 A CN 201310277055A CN 104281587 B CN104281587 B CN 104281587B
Authority
CN
China
Prior art keywords
connection
database
definite
resource group
queue
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.)
Active
Application number
CN201310277055.2A
Other languages
Chinese (zh)
Other versions
CN104281587A (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.)
Advanced New Technologies Co Ltd
Original Assignee
Alibaba Group Holding 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 Alibaba Group Holding Ltd filed Critical Alibaba Group Holding Ltd
Priority to CN201310277055.2A priority Critical patent/CN104281587B/en
Publication of CN104281587A publication Critical patent/CN104281587A/en
Application granted granted Critical
Publication of CN104281587B publication Critical patent/CN104281587B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/90Details of database functions independent of the retrieved data types
    • G06F16/903Querying
    • G06F16/90335Query processing

Abstract

This application discloses a kind of method and device for establishing connection, the problem of to solve all connections during APP may take database connection pool when accessing hot spot data in the prior art, waste the resource of database connection pool.Link division in the database connection pool of APP is in advance at least two queues by this method, at least one connection is included in each queue, in access target data, APP is according to the identification information of target data and default identification information and the correspondence of individual queue, determine queue corresponding to the identification information of the target data, and pass through the target data in connected reference database idle in definite queue.Pass through the above method, even if APP takes multiple connected reference hot spot datas at the same time, APP at most can only also take all connections in queue corresponding to identification information of the hot spot data, without taking all connections in database connection pool, therefore can effectively save the resource in database connection pool.

Description

A kind of method and device for establishing connection
Technical field
This application involves field of communication technology, more particularly to a kind of method and device for establishing connection.
Background technology
At present, apply(Application, APP)Information exchange between database has been prevalent in various answer With in scene.
When APP and database carry out information exchange, APP first has to be connected with Database, then the company based on foundation Connect and carry out information exchange with database.But since database and the process of APP foundation connections are comparatively laborious, establish connection institute The time needed is longer, and is also required to expend the more resource of database, therefore, in the prior art, is preset usually in APP Database connection pool, APP can be connected by the database connection pool with Database.
Specifically, in the prior art, for an APP, the certain amount of the APP and database can be pre-established (Such as 10)Connection, and by have built up this it is a certain number of connection be stored in database connection pool, as APP and data When storehouse connects, then directly connection idle in database connection pool can be used to carry out information exchange with database.
But when some data in database are the higher hot spot datas of visit capacity, APP is likely to data of using up All connections in the connection pool of storehouse cause APP to access other non-thermal point datas to access the hot spot data in database When, the connection for not having the free time in database connection pool can use.Moreover, in order to ensure the accuracy of the data in database, work as APP When by multiple connections the same data in database are carried out with repeatedly renewal operation, database is operated for this multiple renewal Serially perform, therefore, even if APP occupies all connections in database connection pool to same in database at the same time Hot spot data is updated, and database is also what is serially performed against multiple renewal operations, this obviously wastes database connection Resource in pond.
The content of the invention
The embodiment of the present application provides a kind of method and device for establishing connection, is being accessed to solve APP in the prior art The problem of all connections in database connection pool may be taken during hot spot data, waste the resource of database connection pool.
A kind of method for establishing connection provided by the embodiments of the present application, including:
According to the identification information of target data, and default identification information with database connection pool individual queue it is corresponding Relation, determines queue corresponding with the identification information of the target data in the database connection pool, wherein, in advance by described in Link division in database connection pool is at least two queues, and at least one connection is included in each queue;
Pass through the target data in connected reference database idle in definite queue.
A kind of method for establishing connection provided by the embodiments of the present application, including:
According to the identification information of target data, and default identification information and the correspondence of each virtual resource group, really Determine virtual resource group corresponding to the identification information of the target data;
Judge whether the quantity of the connection in definite virtual resource group is pre- less than for the definite virtual resource group If maximum number of connections;
If so, then by link division idle in the database connection pool into the definite virtual resource group, lead to The target data in connected reference database idle in the definite virtual resource group is crossed, and is accessing the target After data by the Connection Release of occupancy into the database connection pool;
Otherwise, will when waiting until that the quantity of the connection in the definite virtual resource group is less than the maximum number of connections Idle link division passes through the definite virtual money into the definite virtual resource group in the database connection pool The target data in the group of source in idle connected reference database, and by the connection of occupancy after the target data is accessed It is discharged into the database connection pool.
A kind of device for establishing connection provided by the embodiments of the present application, including:
Determining module, for the identification information according to target data, and default identification information and database connection pool The correspondence of middle individual queue, determines queue corresponding with the identification information of the target data in the database connection pool, Wherein, by the link division in the database connection pool it is in advance at least two queues, comprising at least one in each queue Connection;
Link block, described in connected reference database idle in the queue that is determined by the determining module Target data.
A kind of device for establishing connection provided by the embodiments of the present application, including:
Determining module, for the identification information according to target data, and default identification information and each virtual resource group Correspondence, determine virtual resource group corresponding to the identification information of the target data;
Whether judgment module, the quantity of the connection in the virtual resource group determined for judging the determining module are less than pin To the definite default maximum number of connections of virtual resource group;
Link block, will be idle in the database connection pool for when the judging result of the judgment module is is Link division into the definite virtual resource group, pass through connected reference number idle in the definite virtual resource group According to the target data in storehouse, and by the Connection Release of occupancy to the database connection pool after the target data is accessed In;When the judgment module judging result for it is no when, wait until that the quantity of connection in the definite virtual resource group is small When the maximum number of connections, by link division idle in the database connection pool to the definite virtual resource group In, by the target data in connected reference database idle in the definite virtual resource group, and accessing institute State the Connection Release of occupancy after target data into the database connection pool.
The embodiment of the present application provides a kind of method and device for establishing connection, and this method in advance connects the database of APP Link division in pond is at least two queues, and at least one connection, in access target data, APP are included in each queue According to the identification information of target data and default identification information and the correspondence of individual queue, the mark of the target data is determined Know the corresponding queue of information, and pass through the target data in connected reference database idle in definite queue.By upper Method is stated, even if APP takes multiple connected reference hot spot datas at the same time, APP at most can only also take the mark of the hot spot data All connections in the corresponding queue of information, without taking all connections in database connection pool, therefore can effectively save Resource in database connection pool.
Brief description of the drawings
Fig. 1 is the process of the first foundation connection provided by the embodiments of the present application;
Fig. 2 is the schematic diagram that the link division provided by the embodiments of the present application by database connection pool is multiple queues;
Fig. 3 is the second provided by the embodiments of the present application process for establishing connection;
Fig. 4 is each virtual resource group schematic diagram in database connection pool provided by the embodiments of the present application;
Fig. 5 is the apparatus structure schematic diagram of the first foundation connection provided by the embodiments of the present application;
Fig. 6 is the second provided by the embodiments of the present application apparatus structure schematic diagram for establishing connection.
Embodiment
By the link division in the database connection pool of APP it is in advance at least two queues in the embodiment of the present application, each At least one connection, and the identification information of each data and the correspondence of individual queue in presetting database are included in queue, in APP During access target data, corresponding queue can be determined according to the identification information of target data, and by idle in definite queue Connected reference target data.By the above method, even if APP, at the same time by the same data of multiple connected references, APP is not yet All connections in database connection pool can all be taken, therefore can avoid wasting the resource in database connection pool.
With reference to Figure of description, the embodiment of the present application is described in detail.
Fig. 1 is the process of the first foundation connection provided by the embodiments of the present application, specifically includes following steps:
S101:According to the identification information of target data, and default identification information and individual queue in database connection pool Correspondence, determine queue corresponding with the identification information of target data in database connection pool.
In the embodiment of the present application, an APP can be directed to, in advance by the link division in the database connection pool of the APP For at least two queues, include at least one connection in each queue, and in presetting database the identification information of each data with it is each The correspondence of queue, as shown in Figure 2.
Fig. 2 is the schematic diagram that the link division provided by the embodiments of the present application by database connection pool is multiple queues. Assuming that including 10 connections in the database connection pool of APP altogether, this 10 connections are the companies of the APP and database pre-established Connect, be then 4 queues by this 10 link divisions in fig. 2, be respectively queue 1, queue 2, queue 3, queue 4.Wherein, team There are 4 connections in row 1, respectively there are 2 connections in queue 2, queue 3, queue 4.
In presetting database in the identification information and database connection pool of each data during the correspondence of individual queue, it can incite somebody to action The queue that the identification information of hot spot data is corresponding is arranged to the most queue of the quantity comprising connection, the mark letter of non-thermal point data Cease corresponding queue and be arranged to other queues.Wherein, the identification information of data includes but not limited to ID of data etc..
For example, in fig. 2, queue 1 can be arranged to queue corresponding to the identification information of hot spot data, by queue 2, queue 3rd, queue 4 is arranged to queue corresponding to identification information of non-thermal point data.
S102:Pass through the target data in connected reference database idle in definite queue.
, then can be by definite queue after APP determines queue corresponding to the identification information for the target data to be accessed Target data in idle connected reference database.
Continue to use the example above, it is assumed that the APP target datas to be accessed are hot spot data, individual queue in database connection pool Division is as shown in Fig. 2, queue corresponding to the identification information for having preset hot spot data is queue 1, then APP is true in step S101 Queue corresponding to the identification information of the fixed target data is queue 1, and APP can pass through connection idle in queue 1 in step S102 Access the target data.
By the above method, even if APP access is hot spot data, APP at most can only also take the mark of hot spot data All connections in the corresponding queue of information, the connection without taking other queues also would not be by database connection pool All connections all take, therefore can effectively avoid waste database connection pool in resource.
Further, after APP determines queue corresponding to the identification information of target data by above-mentioned steps S101, such as There is no idle connection in the queue that fruit determines, then whether the quantity being connected with database that can determine whether currently to establish is less than Default maximum quantity.If the quantity being connected with database currently established is less than default maximum quantity, establish with The connection of database, and by the connected reference target data of foundation, that is, at this time APP without using in database connection pool It is being set up with database connected reference target data, but newly-built one with the connection of database, and pass through newly-built this Connected reference target data.If the quantity being connected with database currently established is not less than default maximum quantity, can Directly return and establish failed message, that is, this access target data failure.
Continuation is illustrated by taking Fig. 2 as an example, it is assumed that and APP determines that queue corresponding to the identification information of target data is queue 1, But in queue at this time 1 and whether leisureless connection, the then quantity that APP judges itself to be currently connected with Database are less than Default maximum quantity, if so, then APP creates a connection with database(Without using appointing in queue 2, queue 3, queue 4 What one idle connection), and by newly-built connected reference target data, otherwise, directly return and establish connection failure message.
In addition to using above-mentioned processing method, when APP is believed by the mark of the above-mentioned steps S101 target datas determined Cease there is no during idle connection in corresponding queue, the connection that also may wait in definite queue is released, and monitors wait Time.If the time span waited is no more than predetermined time period, and the connection in definite queue is released, then can be passed through The connected reference target data discharged in definite queue.If the time span waited has reached predetermined time period, but Connection in definite queue is not released yet, then returns and establish connection failure message, that is, this access target data is lost Lose.
Continuation is illustrated by taking Fig. 2 as an example, it is assumed that and APP determines that queue corresponding to the identification information of target data is queue 1, But in queue at this time 1 and leisureless connection, the then connection in APP waiting lists 1 are released, if the time span waited is not More than predetermined time period, and some connection in queue 1 is released, then the connected reference target by being released in queue 1 Data, if the time span waited has reached predetermined time period, but are released still without connection in queue 1, then return Establish connection failure message.
It is above the method for the first foundation connection provided by the embodiments of the present application, in the side of the first above-mentioned foundation connection In method, each connection in database connection pool is once be divided into multiple queues, then the connection in a queue cannot be by other Queue sharing, realizes the stringent isolation of each connection.Illustrate the second provided by the embodiments of the present application side for establishing connection below Method, as shown in Figure 3.
Fig. 3 is the second provided by the embodiments of the present application process for establishing connection, specifically includes following steps:
S301:According to the identification information of target data, and default identification information pass corresponding with each virtual resource group System, determines virtual resource group corresponding to the identification information of target data.
S302:Judge whether the quantity of the connection in definite virtual resource group is less than and be directed to the definite virtual resource group Default maximum number of connections, if so, then performing step S303, otherwise performs step S304.
S303:By link division idle in database connection pool into the definite virtual resource group, determined by this Virtual resource group in target data in idle connected reference database, and by the connection of occupancy after access target data It is discharged into database connection pool.
If it is determined that virtual resource group in connection quantity be less than for the definite virtual resource group it is default most Big connection number, then APP is by database connection pool
S304:When waiting until that the quantity of the connection in the definite virtual resource group is less than maximum number of connections, by database Idle link division passes through company idle in the definite virtual resource group into the definite virtual resource group in connection pool The target data in database is asked in receiving, and after access target data by the Connection Release of occupancy into database connection pool.
In the embodiment of the present application, an APP can be directed to, it is empty that at least two are preset in the database connection pool of the APP Intend resource group, corresponding maximum number of connections is preset for each virtual resource group, for a default maximum of virtual resource group Connect the quantity for the connection that number is less than in database connection pool, and the identification information of each data in presetting database with it is each virtual The correspondence of resource group.Wherein, the identification information of data includes but not limited to ID of data etc., as shown in Figure 4.
Fig. 4 is each virtual resource group schematic diagram in database connection pool provided by the embodiments of the present application, in Fig. 4, right For a virtual resource group, when the non-access identities information of APP is the data of the corresponding identification information of virtual resource group, Connection in database connection pool will not be divided into the virtual resource group, and when APP access identities information is the virtual money During the data of the corresponding identification information of source group, the connection in database connection pool can be then divided into the virtual resource group, with The data are accessed for APP to use, wherein, the connection being divided into the virtual resource group, which is no more than, is directed to the virtual resource group Default maximum number of connections.After APP accesses end of data, the connection in the used virtual resource group can be discharged again Into database connection pool.
In Fig. 4,10 connections are shared in database connection pool, 4 virtual resources are provided with database connection pool Group, is respectively resource group 1, resource group 2, resource group 3, resource group 4.Wherein, for 2 default maximum of resource group 1 and resource group Connection number is 5, is 3 for resource group 3 and 4 default maximum number of connections of resource group.
Due to second establish connection method be different from the first foundation connection method, virtual resource group not be by All connections in database connection pool carry out stringent isolation, but when needing the connection in database connection pool(That is, when When APP access identities information is the data of the corresponding identification information of virtual resource group), one is taken out from database connection pool Connection is included in the virtual resource group, and data are returned from the virtual resource group after using the connection, then by the connection Storehouse connection pool, therefore, the company that can be more than for the sum of each default maximum number of connections of virtual resource group in database connection pool The quantity connect, is 11 as being directed to the sum of each default maximum number of connections of virtual resource group in Fig. 4, and the company in database connection pool The quantity connect is 10.
Continuation is illustrated by taking Fig. 4 as an example, it is assumed that virtual resource corresponding to the identification informations of the APP target datas to be accessed Group is resource group 1, is 5 for 1 default maximum number of connections of resource group, then APP judges the quantity of the connection in Current resource group 1 Whether 5 are less than.If so, then by an idle link division in database connection pool into resource group 1, and by being divided into money Idle connected reference target data in source group 1, after access target data, then by used connection from resource group 1 It is discharged into database connection pool.If the quantity of the connection in Current resource group 1 waits until resource group 1 not less than 5, APP In the quantity of connection when being less than 5, then by an idle link division in database connection pool into resource group 1, and pass through The idle connected reference target data being divided into resource group 1, connects from money after access target data, then by used It is discharged into source group 1 in database connection pool.
By the above method, even if APP takes multiple connected reference hot spot datas at the same time, APP accesses the hot spot data institute The quantity of the connection of occupancy is no more than the maximum number of connections of virtual resource group corresponding to identification information of the hot spot data, and All connections in database connection pool will not be taken, therefore can effectively save the resource in database connection pool, can reach with It is provided by the embodiments of the present application the first establish the identical effect of method of connection.
Further, after APP determines virtual resource group corresponding to the identification information of target data by step S301, If it is determined that virtual resource group in connection quantity be less than be directed to the definite default maximum number of connections of virtual resource group, But there is no the connection of free time in current database connection pool, then APP can determine whether the quantity being connected with database that itself is established Whether default maximum quantity is less than.If being less than, the connection with database, and the connected reference number of targets for passing through foundation are established According to, that is, at this time APP without using the connection with database being had built up in database connection pool, but newly-built one with number According to the connection in storehouse, and use newly-built connected reference target data.If being not less than, APP can directly be returned and be established connection failure Message, that is, this access target data failure.
Further, in step s 304, if it is determined that virtual resource group in connection quantity not less than being directed to The definite default maximum number of connections of virtual resource group, then connections of the APP in the definite virtual resource group is waited When quantity is less than maximum number of connections, the time span of wait can be also monitored.If the time waited is not up to default Between length, and the quantity of the connection in the definite virtual resource group is already less than maximum number of connections, then by database connection pool Middle idle link division carries out subsequent step into the definite virtual resource group.If the time waited has reached Predetermined time period, but the quantity of the connection in the definite virtual resource group is not less than maximum number of connections yet, then can return to and build Vertical connection failure message, this access target data failure.
It is above the method provided by the embodiments of the present application for establishing connection, based on same thinking, the embodiment of the present application is also Two kinds of devices for establishing connection are provided, as shown in Figure 5 and Figure 6.
Fig. 5 is the apparatus structure schematic diagram of the first foundation connection provided by the embodiments of the present application, is specifically included:
Determining module 501, is connected for the identification information according to target data, and default identification information with database The correspondence of individual queue in pond, determines team corresponding with the identification information of the target data in the database connection pool Row, wherein, it is in advance at least two queues by the link division in the database connection pool, at least one is included in each queue A connection;
Link block 502, for by connected reference database idle in the definite queue of the determining module 501 The target data.
The link block 502 is additionally operable to, when in definite queue there is no idle connection, and currently establish with institute When stating the quantity of the connection of database and being less than default maximum quantity, the connection with the database is established, and pass through foundation Target data described in connected reference;When in definite queue there is no idle connection, it is and currently establishing with the database The quantity of connection when being not less than default maximum quantity, connection failure message is established in return.
The link block 502 is additionally operable to, when, there is no during idle connection, wait is described definite in definite queue Connection in queue is released;If the time span waited is no more than predetermined time period, and in the definite queue Connection is released, then by the target data of the connected reference database discharged in the definite queue;If wait Time span reach predetermined time period, and the connection in the definite queue is not released, then returns and establish connection and lose Lose message.
The first specific above-mentioned device for establishing connection corresponds to the first foundation connection provided by the embodiments of the present application Method.
Fig. 6 is the second provided by the embodiments of the present application apparatus structure schematic diagram for establishing connection, is specifically included:
Determining module 601, for the identification information according to target data, and default identification information and each virtual resource The correspondence of group, determines virtual resource group corresponding to the identification information of the target data;
Judgment module 602, whether the quantity of the connection in the virtual resource group definite for judging the determining module 601 Less than for the definite default maximum number of connections of virtual resource group;
Link block 603, for when the judgment module 602 judging result for be when, by the database connection pool Middle idle link division passes through connection idle in the definite virtual resource group into the definite virtual resource group The target data in database is accessed, and by the Connection Release of occupancy to the database after the target data is accessed In connection pool;When the judging result of the judgment module 602 is no, the connection in the definite virtual resource group is waited until Quantity when being less than the maximum number of connections, by link division idle in the database connection pool to described definite virtual In resource group, by the target data in connected reference database idle in the definite virtual resource group, and Access the Connection Release of occupancy after the target data into the database connection pool.
The link block 603 is additionally operable to, when the judging result of the judgment module 602 be yes and the database connect Connecing does not have the connection of free time and currently the establish quantity being connected with the database in pond is less than default maximum quantity When, the connection with the database is established, and pass through target data described in the connected reference of foundation;When the judgment module 602 Judging result be yes and there is no the connection of free time in the database connection pool and currently establish with the database When the quantity of connection is not less than default maximum quantity, connection failure message is established in return.
The link block 603 is additionally operable to, when the judging result of the judgment module 602 is no, by the database Before idle link division is into the definite virtual resource group in connection pool, determine to wait the definite virtual resource The time that the quantity of connection in group is less than the maximum number of connections is not up to predetermined time period.
Specific above-mentioned second device for establishing connection corresponds to second provided by the embodiments of the present application foundation and connects Method.
The embodiment of the present application provides a kind of method and device for establishing connection, and this method in advance connects the database of APP Link division in pond is at least two queues, and at least one connection, in access target data, APP are included in each queue According to the identification information of target data and default identification information and the correspondence of individual queue, the mark of the target data is determined Know the corresponding queue of information, and pass through the target data in connected reference database idle in definite queue.By upper Method is stated, even if APP takes multiple connected reference hot spot datas at the same time, APP at most can only also take the mark of the hot spot data All connections in the corresponding queue of information, without taking all connections in database connection pool, therefore can effectively save Resource in database connection pool.
It should be understood by those skilled in the art that, embodiments herein can be provided as method, system or computer program Product.Therefore, the application can use the reality in terms of complete hardware embodiment, complete software embodiment or combination software and hardware Apply the form of example.Moreover, the application can use the computer for wherein including computer usable program code in one or more Usable storage medium(Including but not limited to magnetic disk storage, CD-ROM, optical memory etc.)The computer program production of upper implementation The form of product.
In a typical configuration, computing device includes one or more processors (CPU), input/output interface, net Network interface and memory.
Memory may include computer-readable medium in volatile memory, random access memory (RAM) and/or The forms such as Nonvolatile memory, such as read-only storage (ROM) or flash memory (flash RAM).Memory is computer-readable medium Example.
Computer-readable medium includes permanent and non-permanent, removable and non-removable media can be by any method Or technology come realize information store.Information can be computer-readable instruction, data structure, the module of program or other data. The example of the storage medium of computer includes, but are not limited to phase transition internal memory (PRAM), static RAM (SRAM), moves State random access memory (DRAM), other kinds of random access memory (RAM), read-only storage (ROM), electric erasable Programmable read only memory (EEPROM), fast flash memory bank or other memory techniques, read-only optical disc read-only storage (CD-ROM), Digital versatile disc (DVD) or other optical storages, magnetic cassette tape, the storage of tape magnetic rigid disk or other magnetic storage apparatus Or any other non-transmission medium, the information that can be accessed by a computing device available for storage.Define, calculate according to herein Machine computer-readable recording medium does not include non-temporary computer readable media (transitory media), such as the data-signal and carrier wave of modulation.
The application is with reference to method, the equipment according to the embodiment of the present application(System)And the flow of computer program product Figure and/or block diagram describe.It should be understood that it can be realized by computer program instructions every first-class in flowchart and/or the block diagram The combination of flow and/or square frame in journey and/or square frame and flowchart and/or the block diagram.These computer programs can be provided The processors of all-purpose computer, special purpose computer, Embedded Processor or other programmable data processing devices is instructed to produce A raw machine so that the instruction performed by computer or the processor of other programmable data processing devices, which produces, to be used in fact The device for the function of being specified in present one flow of flow chart or one square frame of multiple flows and/or block diagram or multiple square frames.
These computer program instructions, which may also be stored in, can guide computer or other programmable data processing devices with spy Determine in the computer-readable memory that mode works so that the instruction being stored in the computer-readable memory, which produces, to be included referring to Make the manufacture of device, the command device realize in one flow of flow chart or multiple flows and/or one square frame of block diagram or The function of being specified in multiple square frames.
These computer program instructions can be also loaded into computer or other programmable data processing devices so that counted Series of operation steps is performed on calculation machine or other programmable devices to produce computer implemented processing, thus in computer or The instruction performed on other programmable devices is provided and is used for realization in one flow of flow chart or multiple flows and/or block diagram one The step of function of being specified in a square frame or multiple square frames.
Although having been described for the preferred embodiment of the application, those skilled in the art once know basic creation Property concept, then can make these embodiments other change and modification.So appended claims be intended to be construed to include it is excellent Select embodiment and fall into all change and modification of the application scope.
Obviously, those skilled in the art can carry out the embodiment of the present application various modification and variations without departing from this Shen Please embodiment spirit and scope.In this way, if these modifications and variations of the embodiment of the present application belong to the application claim And its within the scope of equivalent technologies, then the application is also intended to comprising including these modification and variations.

Claims (12)

  1. A kind of 1. method for establishing connection, it is characterised in that including:
    Closed according to the identification information of target data, and default identification information with the corresponding of individual queue in database connection pool System, determines queue corresponding with the identification information of the target data in the database connection pool, wherein, in advance by the number It is at least two queues according to the link division in the connection pool of storehouse, at least one connection is included in each queue;
    Pass through the target data in connected reference database idle in definite queue.
  2. 2. the method as described in claim 1, it is characterised in that the method further includes:
    When the connection that the free time is not present in definite queue, and the quantity being connected with the database currently established is less than in advance If maximum quantity when, establish with the connection of the database, and pass through target data described in the connected reference of foundation;
    When the connection that the free time is not present in definite queue, and the quantity being connected with the database currently established is not less than During default maximum quantity, connection failure message is established in return.
  3. 3. the method as described in claim 1, it is characterised in that the method further includes:
    When, there is no during idle connection, the connection in the wait definite queue is released in definite queue;
    If the time span waited is no more than predetermined time period, and the connection in the definite queue is released, then is led to The target data of the connected reference database discharged is crossed in the definite queue;
    If the time span waited reaches predetermined time period, and the connection in the definite queue is not released, then is returned Return and establish connection failure message.
  4. A kind of 4. method for establishing connection, it is characterised in that including:
    According to the identification information of target data, and default identification information and the correspondence of each virtual resource group, institute is determined State virtual resource group corresponding to the identification information of target data;
    Judge whether the quantity of the connection in definite virtual resource group is default less than for the definite virtual resource group Maximum number of connections;
    If so, then by link division idle in database connection pool into the definite virtual resource group, by described true The target data in fixed virtual resource group in idle connected reference database, and will after the target data is accessed The Connection Release of occupancy is into the database connection pool;
    Otherwise, when waiting until that the quantity of the connection in the definite virtual resource group is less than the maximum number of connections, by described in Idle link division passes through the definite virtual resource group into the definite virtual resource group in database connection pool The target data in middle idle connected reference database, and by the Connection Release of occupancy after the target data is accessed Into the database connection pool;
    When the quantity of the connection in the definite virtual resource group is default most less than for the definite virtual resource group What is do not had the connection of free time in big connection number and the database connection pool and currently establish is connected with the database When quantity is less than default maximum quantity, the connection with the database is established, and pass through target described in the connected reference of foundation Data.
  5. 5. method as claimed in claim 4, it is characterised in that the method further includes:
    When the quantity of the connection in the definite virtual resource group is default most less than for the definite virtual resource group What is do not had the connection of free time in big connection number and the database connection pool and currently establish is connected with the database When quantity is not less than default maximum quantity, connection failure message is established in return.
  6. 6. method as claimed in claim 4, it is characterised in that when the connection in the definite virtual resource group quantity not During less than maximum number of connections default for the definite virtual resource group, by connection idle in the database connection pool Before being divided into the definite virtual resource group, the method further includes:
    Determine to wait the quantity of the connection in the definite virtual resource group to be not up to less than the time of the maximum number of connections Predetermined time period.
  7. A kind of 7. device for establishing connection, it is characterised in that including:
    Determining module, for each in the identification information according to target data, and default identification information and database connection pool The correspondence of queue, determines queue corresponding with the identification information of the target data in the database connection pool, wherein, It is in advance at least two queues by the link division in the database connection pool, at least one connection is included in each queue;
    Link block, for the target in connected reference database idle in the queue that is determined by the determining module Data.
  8. 8. device as claimed in claim 7, it is characterised in that the link block is additionally operable to, and is not deposited when in definite queue In idle connection, and when the quantity being connected with the database currently established is less than default maximum quantity, establish and The connection of the database, and pass through target data described in the connected reference of foundation;When there is no the free time in definite queue Connection, the and when quantity being connected with the database currently established be not less than default maximum quantity, returns to establish and connects Failed message.
  9. 9. device as claimed in claim 7, it is characterised in that the link block is additionally operable to, and is not deposited when in definite queue In idle connection, the connection in the definite queue is waited to be released;If the time span waited is no more than default Time span, and the connection in the definite queue is released, then the connected reference by being discharged in the definite queue The target data of database;If the time span waited reaches predetermined time period, and in the definite queue Connection is not released, then returns and establish connection failure message.
  10. A kind of 10. device for establishing connection, it is characterised in that including:
    Determining module, for the identification information according to target data, and default identification information and pair of each virtual resource group It should be related to, determine virtual resource group corresponding to the identification information of the target data;
    Judgment module, whether the quantity of the connection in the virtual resource group determined for judging the determining module, which is less than, is directed to institute State the definite default maximum number of connections of virtual resource group;
    Link block, for when the judging result of the judgment module is is, connection idle in database connection pool to be drawn Assign in the definite virtual resource group, by connected reference database idle in the definite virtual resource group The target data, and after the target data is accessed by the Connection Release of occupancy into the database connection pool;Work as institute State the judging result of judgment module for it is no when, wait until the connection in the definite virtual resource group quantity be less than it is described most During big connection number, by link division idle in the database connection pool into the definite virtual resource group, pass through institute The target data in connected reference database idle in definite virtual resource group is stated, and is accessing the target data Afterwards by the Connection Release of occupancy into the database connection pool;When the judging result of the judgment module is yes and the number It is less than default maximum according to the quantity being connected with the database for not having idle connection in the connection pool of storehouse and currently establishing During quantity, the connection with the database is established, and pass through target data described in the connected reference of foundation.
  11. 11. device as claimed in claim 10, it is characterised in that the link block is additionally operable to, when the judgment module Judging result is yes and does not have the connection of free time and the company with the database currently established in the database connection pool When the quantity connect is not less than default maximum quantity, connection failure message is established in return.
  12. 12. device as claimed in claim 10, it is characterised in that the link block is additionally operable to, when the judgment module Judging result for it is no when, by link division idle in the database connection pool into the definite virtual resource group it Before, determine to wait the quantity of the connection in the definite virtual resource group not up to pre- less than the time of the maximum number of connections If time span.
CN201310277055.2A 2013-07-03 2013-07-03 A kind of method and device for establishing connection Active CN104281587B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201310277055.2A CN104281587B (en) 2013-07-03 2013-07-03 A kind of method and device for establishing connection

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201310277055.2A CN104281587B (en) 2013-07-03 2013-07-03 A kind of method and device for establishing connection

Publications (2)

Publication Number Publication Date
CN104281587A CN104281587A (en) 2015-01-14
CN104281587B true CN104281587B (en) 2018-05-11

Family

ID=52256468

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201310277055.2A Active CN104281587B (en) 2013-07-03 2013-07-03 A kind of method and device for establishing connection

Country Status (1)

Country Link
CN (1) CN104281587B (en)

Families Citing this family (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108183833B (en) * 2017-11-29 2021-08-10 努比亚技术有限公司 Response processing method and device and computer readable storage medium
CN109977096A (en) * 2019-03-05 2019-07-05 中国银联股份有限公司 A kind of database connection management method and device
CN111026794A (en) * 2019-11-26 2020-04-17 山东中创软件商用中间件股份有限公司 Data management method, device, equipment and medium based on data source
CN112732441B (en) * 2021-01-07 2022-12-06 众阳健康科技集团有限公司 Connection method, device and system of multi-element dynamic connection pool

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101408899A (en) * 2008-11-21 2009-04-15 北京中企开源信息技术有限公司 Method and apparatus for switching website multiple data sources
CN102024008A (en) * 2009-09-09 2011-04-20 浙江省电力公司 Limitation method of Web server concurrent number

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7418441B2 (en) * 2001-02-28 2008-08-26 International Business Machines Corporation Data loading from a remote data source record by record

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101408899A (en) * 2008-11-21 2009-04-15 北京中企开源信息技术有限公司 Method and apparatus for switching website multiple data sources
CN102024008A (en) * 2009-09-09 2011-04-20 浙江省电力公司 Limitation method of Web server concurrent number

Also Published As

Publication number Publication date
CN104281587A (en) 2015-01-14

Similar Documents

Publication Publication Date Title
US11334382B2 (en) Technologies for batching requests in an edge infrastructure
US11507430B2 (en) Accelerated resource allocation techniques
KR101775227B1 (en) Techniques for routing service chain flow packets between virtual machines
CN107943421B (en) Partition division method and device based on distributed storage system
US20180027061A1 (en) Method and apparatus for elastically scaling virtual machine cluster
WO2017166643A1 (en) Method and device for quantifying task resources
CN106406987A (en) Task execution method and apparatus in cluster
CN105740063A (en) Data processing method and apparatus
CN109144658B (en) Load balancing method and device for limited resources and electronic equipment
CN108063784B (en) Method, device and system for distributing application cluster resources in cloud environment
CN104281587B (en) A kind of method and device for establishing connection
CN109151070B (en) Block chain-based service scheduling method and electronic device for point-to-point CDN (content delivery network)
DE102019112772A1 (en) TECHNOLOGIES FOR A SERVICE QUALITY-CONSCIOUS END-TO-END I / O PLANNING
CN107729137A (en) Server, the method and storage medium of the decryption of block chain sign test
CN107729514A (en) A kind of Replica placement node based on hadoop determines method and device
CN106161256A (en) A kind of processing method and processing device of Border Gateway Protocol (BGP) route
CN110138688A (en) Dynamic adjusts method, apparatus, equipment and the readable storage medium storing program for executing of business interface
CN111966289A (en) Partition optimization method and system based on Kafka cluster
US20180278493A1 (en) Techniques to meet quality of service requirements for a fabric point to point connection
CN106130960A (en) Judgement system, load dispatching method and the device of steal-number behavior
CN104580194A (en) Virtual resource management method and device oriented to video applications
CN108134812A (en) Data processing method and device
CN112269661A (en) Partition migration method and device based on Kafka cluster
EP3984198A1 (en) Smart contract information redirect to updated version of smart contract
CN115442262B (en) Resource evaluation method and device, electronic equipment and storage medium

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant
TR01 Transfer of patent right

Effective date of registration: 20191209

Address after: P.O. Box 31119, grand exhibition hall, hibiscus street, 802 West Bay Road, Grand Cayman, Cayman Islands

Patentee after: Innovative advanced technology Co., Ltd

Address before: Cayman Islands Grand Cayman capital building, a four storey No. 847 mailbox

Patentee before: Alibaba Group Holding Co., Ltd.

TR01 Transfer of patent right