Title of Invention

"A METHOD FOR ADMINISTRATING DATABASE CONNECTION"

Abstract A method for administrating effectually database connection in a database management system, which is in database applications development in order to implement database connection multiplex, sets the number of the created connection and the maximal number of each connection multiplex during the connection pool initialization by establishing the connection pool which is used for storing the database connection; initializing the established connection pool , establishes connection, set the non-business attribute and put it into the connection pool according to the number of the created connection; in the connection pool, establishes and distributes each common connection to make it be multiplexed by connection request; in the connection pool , by using business process method establishes , distributes and connects the business, keeping uniqueness consistency and sustains the nested business; in the connection pool, reclaims the used, connection to make it be multiplexed. It effectually solves the problem that improperly uses connection and unable to multiplex the connection, and also improves the using efficiency of the database, thereby achieves high security and reliability and also high application performance.
Full Text FIELD OF THE INVENTION
The present invention relates to application and development of databases, a method for managing database connections in a database management system (DBMS), the method employing a connection administrating module (CAM) specifically, to an administrating method for databases, whose core idea is about database connections with connection multiplexing, more specifically, to a high effective administrating method for database connection. BACKGROUND OF THE INVENTION
In development of databases, an administration of connection is a difficult problem, which is an important factor for application performance. The connection administration includes management for establishing, using and closing connection. At the beginning, because access to a database is not very frequent, traditional connection management adopts a strategy that is establishing in need and closing when its use is finished, which is classified as two management manners: distributed transactions and working threads. In the methods mentioned above, the establishing connection means asking a connection request to a database management system (DBMS) and establishing a related connection by DBMS before the application begins to access to a database (DB); the using connection means occupying the connection by the application to access to and use the database; the closing connection means releasing or reclaiming the connection occupied by the application according to the situation after the application access is finished.
Transaction manner provides a management method only for distributed transactions, in which an application is internalized as a global transaction and the utilization to a connection by the application is transformed into obtaining and closing the connection through the global transaction. A US patent of Application No. 333141, filed on June 14, 1999, discloses a method for distributed transaction supported by using JDBC 1.0 drivers. It provides a method based on JDBC 1.0 to support distributed transaction, which maintains a mapping table inside for global transactions and connections used by them, rather than distributing a new physical connection for

each connecting request. Because this method is based on transactions, in this manner transactions could not effectively utilize connections during obtaining and closing the connections. Therefore, even when many connection requests are provided to the database in a transaction, still only the same connection remains for using, resulting in a waste of resources.
The other management manner is internalizing an application as a working thread by a thread manner, thus transforming the usage of connection by the application into obtaining and closing the connection through the working thread. A US patent of Application No. 611604, field on July 7, 2000, discloses a method and system of managing connections for a database management system, in which each database management system corresponds to a database system. Through a series of working threads established in the system the requests to the database are distributed to the working threads for implementing, which also includes connecting special connection, working threads and database subsystem used. This thread manner utilizes adequately advantages of computer threads management, and its implement efficiency and application performance are greatly improved. However, because the manner is based on threads, and in this manner the threads could not effectively utilize the connections during obtaining and closing connections. Therefore, when the same working thread calls the same database subsystem, the same connection is still used, leading to low efficiency.
From an analysis for above two kinds of management technologies, it can be seen that they have such disadvantages as the following:
1) the utilization of same connection for same working thread to same subsystem or
the utilization of same connection for same transaction to a database, both equal to
distributing a fixed connection for the application or sub-application no matter what the
real using situation of the connection is, therefore connections are not managed as a
whole, and thus utilization efficiency of the connections is not high;
2) although establishing and closing connections are considered, there are no
decision conditions for establishing and closing connections, and no method and strategy
for establishing, distributing, using and reclaiming connections, and thus
utilization for the connections is not efficient;
3) multiplexing connection could not be used; and
4) no management is involved in distributing and reclaiming connections.
SUMMARY OF THE INVENTION
The object of the present invention is to provide a management method for database connections to overcome the disadvantages of above current technologies. In this method, module encapsulation technology, connection pool design mode, connections management method and transaction process method are adopted for providing an effective method for the multiplexing of common connections and consistency management of transactions connections, so as to multiplex and effectively utilize connections, reduce handshaking overhead caused by establishing connections, and increase database utilization efficiency; to ensure the consistency of transaction connections in a method of composing transactions; to reduce coupling generated by the details of establishing database links and facilitate module maintenance; and to provide connection management guarantee for secure and highly reliable applications with high performance. The module encapsulation technology means a technology that encapsulating into the module a series of strategies, such as reclaiming and distributing of connections resources according to strategies, multiplexing and connection pool initialization.
According to the present invention, it provides a method for managing database connections in a database management system (DBMS) in a client/server structure platform composed of database server across interconnected networks, characterized in that, the method employing a connection administrating module (CAM), said CAM embedded in the system structure platform as components, the method comprising the steps of:
1.1) the CAM building a connection pool for storing database connections, and setting a number of connection to be generated and stored and a maximum number that each of the connections can be multiplexed for the connection pool initialization;
1.2) using the DBMS to initialize the connection pool build and set a connection type when distributing an idle connection or establishing a new connection, which comprises non-transaction attribute for the common connection and transaction attribute for the transaction connection;
Substituted Sheet

1.3) the CAM establishing and distributing a connection for each common
connection request in the connection pool to enable it to be multiplexed;

1.4) using the DBMS to establish, distribute and use transaction connections in the connection pool by using transaction process manner to keep uniqueness and consistency and to support nested transactions; and
1.5) the CAM reclaiming the used connections for re-use in the connection pool.
According to the above method provided by the present invention, a newly establishing connection should be initialized, in which the initialization comprises the following steps:
2.1) using the DBMS to set the non-transaction attribute to the connection;
2.2) providing a reference count for a common connection and a nesting order count for a transaction connection; and
2.3) providing explicit declarations of transaction beginning and end and a
transaction registry table, for the transaction connection.
In the method provided by the present invention, the step (1.3) comprises the following steps:
the CAM checking if there is an idle connection existing in the connection pool,
if true, the connection is distributed directly and the reference counting is started;
if false, the CAM checking if there are available connections that can be multiplexed, if true, the connection with minimum reference count is distributed and its reference count is progressive increasing, otherwise, a new connection is established, distributed and initialized.
In the method provided by the present invention, the step (1.4) comprises the step of using the DBMS to initiate a transaction to obtain a connection, commit and roll back the transaction to release the connection.
In the method provided by the present invention, the step (1.5) comprises:
the CAM checking if the connection pool is full, if true, the reclaimed connection is closed, if false, the reclaimed connection is put into the connection pool.
In the method provided by the present invention, the connection management and connections of database are encapsulated.
In the method provided by the present invention, a reference count is provided

and a maximum multiplexing number is set for each connection by the CAM, every time when a common connection is used the reference count of the connection is progressively increasing; the connection with minimum reference count is chosen as a useable connection, and when the reference count of the connection is less than its maximum multiplexing number, the connection is decided as the one that can be multiplexed; when a connection is multiplexed, it is not distinguished between the connection established during initialization and the connections re-established during program running, the connection established is multiplexed with the highest efficiency.
In the method provided by the present invention, when the number of the connections in the connection pool is less than the number of connection to be generated that should be set by the CAM during initialization of the connection pool, it is decided that the connection is not full by the CAM.
In the method provided by the present invention, the step of using the DBMS to initiate transaction comprises:
the CAM checking if the transaction has occupied a connection,
if true, the connection is still distributed and its nesting order count is progressively increasing;
if false, the CAM checking if there is an idle connection available, if true, the idle connection is distributed, otherwise a new connection is established and distributed.
In the method provided by the present invention, the step of committing and rolling back the transaction comprises:
the CAM checking if the transaction is a nested transaction,
if true, progressively decreasing the nesting order count of the connection;
otherwise, rolling back the transaction;
in which rolling back the transaction includes the following steps:
10.1) using the DBMS to recover the non-transaction attribute of the connection;
10.2) the CAM deleting the corresponding records on the relationship between the transaction's initiator and the used transaction connection from the transaction registry table; and
10.3) the CAM reclaiming the connection.

In the method provided by the present invention, a transaction registry table is provided for each transaction connection by the CAM, when establishing a connection the corresponding relationship between a thread number used by a transaction initiator and the connection used by the transaction is registered by the CAM in the transaction registry table, when ending the connection this corresponding relationship is deleted by the CAM from the transaction registry table; if a transaction has no relationship registered in the transaction registry table, the transaction is decided no connection by the CAM.
In the method provided by the present invention, a nesting order count is provided for each transaction connection by the CAM, which is starting when a connection is establishing, progressively increasing when the connection is used and progressively decreasing when such use is completed; when the nesting order count is bigger than 1, the transaction is decided as a nesting connection.
"In the method provided by the present invention, when a connection pool is established initialization connection, a non-transaction attribute is set by using the DBMS; when a new idle connection is distributed, the connection is initialized by the CAM; when a common connection is reclaimed, its non-transaction attribute is held by the CAM; and when a transaction is returned, its non-transaction attribute is recovered by the CAM, in such way all idle connections are ensured as non-transaction connection, it does not distinguishing between transaction connection and common connection, so that both transaction connection and common connection Can use all idle connections in process of distributing an idle connection.
The administrating method for database connection provided by the present invention can be applied to all kinds of database applications and developments. In a traditional connection management method, a connection is established when needed and closed when the use is completed, and the database is operated to open or close directly by thread and global transactions, which lack connection management and modules isolation. And multiplexing can not be implemented. Compared with traditional connection management methods of transactions and threads, the present invention provides management characteristics such as distributing and reclaiming connections, and transaction connection management consistency, which can be

conveniently added into the whole system as single modules, and the interactions of developing database service applications to database are put into the inside of the process modules provided by invention. The connections are multiplexed with high efficiency and security. In addition, the problems of connection abuse and reclaiming are solved effectively, and using efficiency is greatly increased. Through testing in using efficiency, compared with previous application to connection, the connection administrating module made by the present invention has a great improvement in security of connection management, reliability and efficiency, and a higher practicability.
BRIEF DESCRIPTION OF THE DRAWINGS
Fig.l is a flow chart of establishing, distributing and using common connections by using the method for administrating database connections according to the present invention;
Fig.2 is a flow chart of initiating transactions by transaction process method according to the present invention;
Fig. 3 is a flow chart of committing and rolling back transactions by transaction process method according to the present invention; and
Fig.4 is a flow chart of reclaiming connections according to the present invention.
DESCRIPTION OF THE PREFERRED EMBODIMENT(S)
The method of the present invention will be further described in detail below, illustrating the basic main points of the invented method as follows:
1) A connection pool is built for storing and managing connections. The connection pool can generate connections with the number that is set for initializing the connection pool according to special applications. The connections generated dynamically during program running are put into the connection pool, and the newly established or distributed connections obtained from the connection pool are applied. When the use of a connection is completed the connection is reclaimed or released by the connection pool. The connection pool is a basis for entire connection

management.
2) Connections are classified as two kinds :transaction connection and common
connection, and different management methods are adopted for transaction connection
and common connection according to their different characteristics.
3) Common connection is established, distributed and used, and the existing common
connection is multiplexed.
4) The transaction connection is established, distributed and used by using a transaction process method to ensure consistency of database transaction connection and support nested transaction. Then the connection is reclaimed to enable it to be reused. By this way, the connection can be multiplexed in security, entirely managed and effectively used, and not only common connection is multiplexed but also the consistency of database transaction connection is ensured and nested transaction is supported, so that using efficiency of the database is increased.
5) The original connection and connection administration of the database are encapsulated. Namely, the connection and the connection administration is encapsulated into inside database module(s) provided by the invention, the process logic of application itself is isolated from access logic of special database, and coupling with other modules is reduced, which establishes a base for multiplexing of application itself and facilitates the use to the connection, especially to the transaction connection for an application, thus the development efficiency is increased.
6) Distributing an idle connection is not distinguishing transaction connection and common connection when requesting connections. They are dealt with identically to avoid such situations that when a transaction connection is requested and all transaction connections are used up, an existing idle common connection could not be used; and on the contrary, when a common connection is requested and all common connections are used up, an existing idle transaction connection could not be used.
7) In the method of the present invention, the strategy of multiplexing common
connection and using connection effectively is not distinguishing the static connection
established during initialization and the dynamic connection reestablished during
programs running. (I) The maximum multiplexing number is set according to the
special

situation. The connection available for multiplexed is multiplexed.
For the connection being established, when the reference count of the connection is less than the maximum multiplexing number, the connection can be multiplexed. The reference count is a number of times that a common connection has been multiplexed. The maximum multiplexing number is a number of maximum times that a connection can be multiplexed, which is set by the system. (II) The setting number of original connections in the connection pool is set according to the special situation and the connection that should be reclaimed is reclaimed. When any of the connections being completely used is released, if the number of the connections in the connection pool does not reach the setting number, the connection is reclaimed for later use. In a practical application, the setting number of original connection in the connection pool can decide the frequency of using idle connection and the frequency of establishing connection. The multiplexing efficiency and using efficiency of a connection is ensured through the maximum multiplexing number of a connection and the setting number of original connection in the connection pool.
8) The transaction process method includes initiating transaction, transaction committing and rollback. For a transaction, it is processed by using the transaction process method to let the transaction not directly obtain management for a connection and to ensure the uniqueness of connection used by a transaction, which facilitates other modules to initiate transactions. Meanwhile the transaction can also be organized by using other manners or by calling the method realized, and in a transaction even a transaction method can be called to organize a nested transaction. The transaction process method ensures distributing and reclaiming of a transaction connection, consistently committing of operation in a connection, and the consistency of connections used by the rollback and composing transaction operation. This method satisfies connection requirement for a transaction and does not obstructs connection multiplexing, and thus realizes safely multiplexing.
The present invention provides a method for database connection multiplexing with high efficiency, which is described in each step below:
Step 1: Building and initializing a connection pool.

First, a connection pool is built when a system (DBMS) is initialized. The connection pool sets a setting number of connections to be generated that should be put into the connection pool when initializing according to a special application, meanwhile the maximum multiplexing number that could be reached is set for each connection. Second, the connection pool is initialized. When the system obtains a connection request for the first time, including that for common connection and for transaction connection, the system initializes the connection pool, establishes connections with the setting number, and puts them into the connection pool.
Step 2: Establishing, distributing, initializing and using connections by using a connection pool management method.
Initializing connections particularly means setting the type of the connection when distributing an idle connection or new connection. For a common connection, setting the non-transaction attribute and providing a reference counting. For a transaction connection, setting the transaction attribute and providing nesting order count, meanwhile the explicit declarations of transaction beginning and end (by calling commit or rollback method) and a transaction registry table. In the transaction registry table, the corresponding relationship between the transaction initiator and the connection used by the transaction is registered to ensure the consistency of the connection used by transaction. The table is generated dynamically during the program running according to the practical calling situation. By the table, the part of transaction process is isolated from the part of connection management. In the present invention, the connection used by a transaction is only used by the transaction during the transaction is run, and not allowed to be multiplexed.
As shown in Fig. 1, the present invention uses the connection pool management
method, which avoids the handshaking overhead caused by establishing the link for each
connection, to establish, distribute, initialize and multiplex the common connection. In
the figure, the "start" means executing the step 1 when an application requests a common
connection. In the step 1, if the connection pool has been initiated is checked. If not, the
connection pool is initialized firstly, then to execute the step 2; if yes, the step 2 is
executed directly. In the step 2, if the applicant has existed in the transaction

registry table is checked. If yes, it is indicated that the request to the common connection is a composing part of the transaction, and the consistency of the connection should be kept, so that the connection registered by the applicant in the transaction registry table is provided; if not, the step 3 is executed. In the step 3, if there are any idle connections in the connection pool is checked. If yes, one of the idle connections is provided, and its reference count is started; if not, the step 4 is executed. In the step 4, if there are any connections that can be multiplexed is checked, namely if there are connections whose reference counts do not reach the maximum multiplexing number. If not, a new connection is established, and its reference count is started; if yes, one with the minimum reference count of the connections not reaching the maximum reference count is found out and chosen to be multiplexed, and its reference count is added 1. Multiplexing a connection means that, first, finding an existing connection that can be multiplexed, without distinguishing a connection established during initialization (static connection) from a connection established during program running (dynamic connection), and that is not an idle connection and is not occupied, no matter whether the connection is a common connection or a transaction connection, poping it off the stack (connection pool), and multiplexing it if the connection is a common connection and its reference count is minimum.
As shown in Fig. 2 and Fig. 3, a transaction connection is established, distributed, initialized and uniquely used by calling connection pool management method and using transaction process manner of initiating, committing and rollback. The consistency of the transaction connection in the method composing the transaction can be ensured, and, in addition, the nested transaction is supported.
The Fig. 2 illustrates an operation of initiating a transaction. The box of "start" means the step 1 is executed when an application requests a transaction connection. In the step 1, if the connection pool has been initialized is checked. If not, the connection pool is initialized first, and then the step 2 is executed; if yes, the step 2 is executed directly. In the step 2, if there is the connection registered and used by the transaction initiator in the transaction registry table is checked. If yes, it is indicated that it is a nested

transaction, the connection used by the transaction initiator in the transaction registry table is provided, and its nesting order count is added; if not, the step 3 is executed. In the step 3, if there is any idle connection in the connection pool is checked. If yes, the step 4 is executed directly; if not, a new connection is established, and then the step 4 is executed. In the step 4, the corresponding relationship between the thread number used by the initiator and the connection used by the transaction is registered into the transaction registry table, while the nesting order count is started and the attributes related to the transaction connection are set. All of subsequent accesses to the database initiated by the same transaction are implemented by searching the transaction registry table and using the connection distributed so as to ensure that all operations in the transaction use the same database connection.
Fig. 3 indicates the operation of transactions committng and rollback. The box of "start" means the step of transaction committing and roolback is called when all tasks of transactions are completed. First, the connection used by the transaction is obtained through a transaction connection calling value. And then the type and nesting order of the connection is checked in the transaction registry table. When the connection is NULL or the nesting order is bigger than 1, the transaction that uses the connection is a nested transaction and the nesting order of the connection is progressively decreased. When the connection exists and its nesting order is less than or equal tol, the transaction that uses the connection is not a nested transaction. Then all operations completed in the connection are committed into the database, the connection number is removed from the transaction connection calling value pair, and the non-transaction attribute of the connection is recovered. Meanwhile the transaction initiator and transaction connection used by it are deleted from the transaction registry table. Then the connection is reclaimed by calling the management method of connection pool reclaiming connections. Step 3: the connection is reclaimed by the management method of connection pool.
Fig. 4 shows the operation of reclaiming transaction. The box of "start" means that the step 1 is executed when the use of the connection has been completed. In the step 1, if the connection is null or has been closed is checked. If yes, return is

called; otherwise the step 2 is executed. In the step 2, if the transaction is composed of a series of existing database method is checked, namely if the connection exists in the transaction registry table. If yes, return is called; if not, the step 3 is executed. In the step 3, if the connection is still referred by others is checked, namely if the reclaimer of the connection has been registered in the transaction registry table. If yes, it is indicated that the database method is called by a transaction, because the end of the transaction is implemented by transaction committing or transaction rollback, therefore only the reference count is progressively decreased and no other operations are conducted, and then return is called; if not, the reference count of the connection is checked. If it £ 1 , fail return is called because the connection is still referred by others. If it D 1, the connection is taken out from the current using structure to prepare for reclaiming, and then the step 4 is executed. In the step 4, if the number of the connection in the connection pool has achieved the original setting number is checked. If not, the connection is put into the connection pool; if yes, the connection is closed and reclaimed. Closing a connection means that, when the connection, not distinguishing the connection established during initialization (static connection) from the connection re-established during program running (dynamic connection), having been used is released, pushing it into the stack for later use as long as the connection number in the connection pool does not reach to the original setting number of connection, but not close it even though it is a dynamic connection.
Here we use is an example that it is realized by using JAVA language to explain the invention. First, the object hierarchy of the invention is defined by using object-oriented design method provided by JAVA: establishing connection pool parent object (ConpoolClass, for example) and connection child object (ConnClass, for example), transaction registry table parent object (AfregClass, for example), and transaction child object (AffClass, for example). Second, the function and attribute provided by the invention are defined and described by using the object-oriented design method and JAVA language: defining the number attribute of the connection comprised in the connection pool (LnkNum, for example), the initializing connection number (beginNum, for example),

common connection maximum multiplexing number (muxNum, for example), and
establishing (create(), for example) method, initializing operation (using constructor)
method, and defining the connection pool management method by using key word of
synchronized, including establishing a new connection (creatConn(), for example),
getting a common connection (getCommConn(), for example), releasing a multiplexed
common connection (releaseMuxConn(), for example) and reclaiming a connection
(releaseConn(), for example), so as to ensure the safe multiplexing of common
connection; defining the non-transaction attribute (commTrue, for example) and
occupation attribute (usedTrue, for example) of a connection object, the reference count
attribute of a common connection or the nesting order count (usedNum, for example) of a
transaction connection, and the method of connection initialization operation (using
constructor); defining recording attribute of transaction registry table object (affRecord,
for example), this recording attribute is recording the initiator of the transaction,
transaction connections used (including connection, connection type, and nesting order)
and corresponding relationship between them, and defining registering transaction
(regRecord(), for example) in the starting transaction and deleting transaction
(delRecord(), for example)in the transaction end declaration of transaction registry
table object; defining connection calling attribute of transaction object (usedLink, for
example), and its transaction process method including the methods of initiating
transaction (beginTrans(), for example), committing and rollback
transaction(endTrans(), for example). Third, by using the objects and methods created by above object-oriented, the invention is realized according to the steps as follows:
A connection pool object "thePool" is created for a database by calling Connpool.create (thePool) when system initializating. thePool.beginNum and thePool.muxNum are set and it is also be set for an existing flag of connection pool of database object: poolI:=False. A transaction registry table object is created by calling AffRecord.Create(theRecord). When the system obtains a connection request (described below) of the database for the first time, constructor is called to initialize the connection pool, and the existing flag of connection pool of database object, pooll, is set as True (poolI:=True). In the method, for calling connection pool, thePool.createConn()

creates connection child objects ConnClassN(l≤N≤beginNum) according to the number of thePool.beginNum, sets ConnClassN.usedTrue:=False, and pushes them into connection pool stack.
Furthermore, for the management of common connection request: when an application requests a common connection, if poolI=False, the constructor is called to initialize the connection pool (thepool); if poolI=True, "theRecord" is checked to decide if the application has existed. If yes, the application calls thePool.getCommConn() to return the connection with the connection number recorded by "theRecord". If not, if thePool.ConnClassM.usedTrue=False (1 ≤ M ≤ InkNum), the application calls thePool.getCommConn(thePool.ConnClassM) to choose it. If all connections usedTrue are true, the minimum thePool.ConnClassM is chosen. For usedNum, if thePool.ConnClassM.usedNum Furthermore, for initiating transaction: when an application requests a transaction connection (the transaction object corresponding to the application is AffClassN, N is a nature number), if poolI=False, the constructor is called to initialize the connection pool (thePool). If poolI=True, and if the application exists in the "theRecord", the connection number is found out, and AffClassN. beginTrans() is called to return the connection with the connection number recorded in "theRecord". If the application doesn't exist, and if thePool.ConnClassM.usedTrue=Flase(l ≤ M ≤ InkNum), the application calls AffClassN.beginTrans(thePool.ConnClassM) to choose it. If the usedTrue of all connections are true, thePool.Create(ConnClassK), InkNum := InkNum +1, K:=lnkNum establishes new connections. "theRecord.regRecord (ConnClassK, transaction number)" is called to register. AffClassN.beginTrans (thePool.ConnClassK)

is called to choose. AffClassN.usedLink is set as thePool.ConnClassK.
Furthermore, for transaction committing and rollback, when all tasks of transactions
are completed, AffClassN.endTrans() is called, including getting the connection number
from the parameters of thePool.ConnClass of the transaction AffClassN.beginTrans().
According to the connection number, the connection ConnClassX is checked in
"theRecord". If it is a nested transaction, AffClassN.endTrans() is called. If not, setting
AffClassN.usedLink:=NULL, ConnClass.commTrue:=True,
theRecord.delRecord(AffClassN) is called to delete the register, and thePool.ReleaseConn(ConnClassX) is called to reclaim the connection.
Furthermore, for reclaiming connection, when the use of connection ConnClassX is completed, thePool.releaseConn(ConnClassX) is called. ReleaseConn() includes: if connection occupation ConnClassX.usedTrue=True, return operation is executed. For ConnClassX.usedTrue=False, the connection type is checked. If a transaction is made up of a serial of database methods that has existed, namely that the connection exists in theRecord, return operation is executed. For the connection called by transaction, AffClassX.endTrans() is called. For the situation of ConnClassX.commTrue:=True, if ConnClass.usedNum>l, thePool.releaseMuxConn (ConnClassX) is called; if ConnClass.usedNum≤l, and if thePool.lnkNumDthePool.beginNum, destructor is called to release the connection ConnClassX; otherwise, setting ConnClassX.usedTrue:=False.
The system mentioned by embodiment of the invention is Database Management System (DBMS).









We claim:
1. A method for managing database connections in a database management system
(DBMS) in a client/server structure platform composed of database server across
interconnected networks, characterized in that, the method employing a connection
administrating module (CAM), said CAM embedded in the system structure platform as
components, the method comprising the steps of:
1.1) building a connection pool for storing database connections using the CAM, and setting a number of connections to be generated and a maximum number that each of the connections can be multiplexed for the connection pool initialization;
1.2) initializing the connection pool built using the DBMS, and set a connection type when distributing an idle connection or establishing a new connection, which comprises non-transaction attribute for the common connection and transaction attribute for the transaction connection;
1.3) establishing and distributing a connection for each common connection request in the connection pool to enable it to be multiplexed by the CAM

1.4) establishing, distributing and using transaction connections in the connection pool by using transaction process manner to keep uniqueness and consistency and to support nested transactions by using DBMS; and
1.5) reclaiming the used connections for re-use in the connection pool by the CAM.
2. The method as claimed in claim 1, wherein, the new established connection
should be initialized, the initialization comprises the following steps:
2.1) using the DBMS to set the non-transaction attribute of the connection;
2.2) providing a reference count for a common connection and a nesting order count for a transaction connection; and
2.3) providing explicit declarations of transaction beginning and end and a transaction registry table, for the transaction connection.
3. The method as claimed in to claim 1, wherein the step (1.3) comprises the
following steps:
the CAM checking if there is an idle connection existing in the connection pool; if true, the connection is distributed directly and the reference counting is started;

if false, checking if there are available connections that can be multiplexed, if true, the connection with minimum reference count is distributed and its reference count is progressive increasing, otherwise, a new connection is established, distributed and initialized.
4. The method as claimed in claim 1, wherein the step (1.4) comprises the step of using the DBMS to initiate a transaction to obtain a connection, commit and roll back the transaction to release the connection.
5. The method as claimed in claim 1, wherein the step (1.5) comprises the following steps:
the CAM checking if the connection pool is full; if true, the reclaimed connection is closed, if false, the reclaimed connection is put into the connection pool.
6. The method as claimed in claim 1, 2, 3,4, or 5, wherein the connection management and the connections of database are encapsulated.
7. The method as claimed in claim 1, 2 or 3, wherein each of the connection is provided a reference count and set a maximum multiplexing number by the CAM, the reference count of the connection is progressively increasing every time the common connection is used; the connection with minimum reference count is chosen as a useable connection, and when the reference count of the connection is less than its maximum multiplexing number, it is decided that the connection can be multiplexed; in the process of connection multiplexing, both the connections established during initialization and the connections re-established during program running can be multiplexed with the highest efficiency.
8. The method as claimed in claim 1 or 5, wherein in the step of the CAM setting the number of connections to be generated that should be put into the connection pool when initialization, if the number of the connections in the connection pool is less than the setting number, it is decided that the connection is not full.
9. The method as claimed in claim 4, wherein the step of using the DBMS to initiate a transaction comprises:
the CAM checking if the transaction has occupied a connection; if true, the connection is still distributed and its nesting order count is progressively increasing;
if false, the CAM checking if there is an idle connection available; if true, the idle connection is distributed, otherwise a new connection is established by using the DBMS and distributed.
10. The method as claimed in claim 4, wherein the step of the committing and
rolling back the transaction comprises:
the CAM checking if the transaction is a nested transaction,
if true, progressively decreasing the nesting order count of the connection;
otherwise, rolling back the transaction;
in which rolling back the transaction includes the following steps:
10.1) using the DBMS to recover the non-transaction attribute of the connection;
10.2) the CAM deleting the corresponding records on the relationship between a transaction's initiator and the used transaction connection from the transaction registry table; and
10.3) the CAM reclaiming the connection.

11. The method as claimed in claim 2, 9, or 10, wherein a transaction registry table is provided for each transaction by the CAM, into which the corresponding relationship between a thread number used by a transaction initiator and the connection used by the transaction is registered by the CAM when establishing, and from which the relationship register is deleted by the CAM when ending; if a transaction has no the relationship registered in the transaction registry table, it is decided that there is no connection corresponding to the transaction by the CAM.
12. The method as claimed in claim 11, wherein a nesting order count is provided for each transaction connection by the CAM, which is starting when a connection is establishing, progressively increasing every time when the connection is used and progressively decreasing every time when the use is completed; when the nesting order count is bigger than 1, the transaction is decided as a nesting connection.
13. The method as claimed in claim 1, 2, or 10, wherein when an original connection is established in the connection pool, a non-transaction attribute is set by using the DBMS; when a new idle connection is distributed, the connection is initialized by the CAM; when a common connection is reclaimed, its non-transaction attribute is held by the CAM; and when a transaction is returned, its non-transaction attribute is
recovered by the CAM to keep that all idle connections are non-transaction connections, so that both transaction connection and common connection can use all idle connections in process of distributing the idle connection.
14. The method as claimed in claim 1, wherein the CAM is added into the DBMS as single module.

Documents:

3249-DELNP-2005-Abstract-(08-05-2009).pdf

3249-delnp-2005-abstract.pdf

3249-DELNP-2005-Claims-(08-05-2009).pdf

3249-delnp-2005-Claims-(23-12-2010).pdf

3249-delnp-2005-Claims-(31-03-2010).pdf

3249-delnp-2005-claims.pdf

3249-DELNP-2005-Correspondence-Others-(08-05-2009).pdf

3249-DELNP-2005-Correspondence-Others-(18-05-2009).pdf

3249-delnp-2005-Correspondence-Others-(23-12-2010).pdf

3249-DELNP-2005-Correspondence-Others-(26-07-2010).pdf

3249-DELNP-2005-Correspondence-Others-(31-03-2010).pdf

3249-delnp-2005-correspondence-others.pdf

3249-DELNP-2005-Corresponence-Others-(05-05-2009).pdf

3249-DELNP-2005-Description (Complete)-(08-05-2009).pdf

3249-delnp-2005-Description (Complete)-(23-12-2010).pdf

3249-delnp-2005-description (complete).pdf

3249-DELNP-2005-Drawings-(08-05-2009).pdf

3249-delnp-2005-drawings.pdf

3249-delnp-2005-form-1.pdf

3249-delnp-2005-form-13-(08-05-2009).pdf

3249-delnp-2005-form-18.pdf

3249-DELNP-2005-Form-2-(08-05-2009).pdf

3249-delnp-2005-form-2.pdf

3249-delnp-2005-Form-26-(31-03-2010).pdf

3249-DELNP-2005-Form-3-(08-05-2009).pdf

3249-delnp-2005-form-3.pdf

3249-delnp-2005-form-5.pdf

3249-delnp-2005-gpa.pdf

3249-delnp-2005-pct-237.pdf

3249-delnp-2005-pct-326.pdf

3249-delnp-2005-pct-373.pdf


Patent Number 247446
Indian Patent Application Number 3249/DELNP/2005
PG Journal Number 15/2011
Publication Date 15-Apr-2011
Grant Date 07-Apr-2011
Date of Filing 22-Jul-2005
Name of Patentee ZTE CORPORATION
Applicant Address ZTE PLAZA, KEJI ROAD SOUTH HI-TECH INDUSTRIAL PARK, NANSHAN DISTRICT,SHENZHEN, GUANGDONG 518057 (CN)
Inventors:
# Inventor's Name Inventor's Address
1 SUN, MING ZTE PLAZA, KEJI ROAD SOUTH HI-TECH INDUSTRIAL PARK, NANSHAN DISTRICT,SHENZHEN, GUANGDONG 518057 (CN)
PCT International Classification Number H04L 12/24
PCT International Application Number PCT/CN2003/001016
PCT International Filing date 2003-11-28
PCT Conventions:
# PCT Application Number Date of Convention Priority Country
1 02139948.4 2002-12-25 China