CN101840352A - Method and device for monitoring database connection pool - Google Patents

Method and device for monitoring database connection pool Download PDF

Info

Publication number
CN101840352A
CN101840352A CN201010160673A CN201010160673A CN101840352A CN 101840352 A CN101840352 A CN 101840352A CN 201010160673 A CN201010160673 A CN 201010160673A CN 201010160673 A CN201010160673 A CN 201010160673A CN 101840352 A CN101840352 A CN 101840352A
Authority
CN
China
Prior art keywords
database
object instance
class
jdbc
sql statement
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.)
Granted
Application number
CN201010160673A
Other languages
Chinese (zh)
Other versions
CN101840352B (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.)
Beijing CIIC Runbang Technology Co. Ltd.
Original Assignee
ZTE Corp
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 ZTE Corp filed Critical ZTE Corp
Priority to CN201010160673.5A priority Critical patent/CN101840352B/en
Publication of CN101840352A publication Critical patent/CN101840352A/en
Priority to PCT/CN2010/077270 priority patent/WO2011134233A1/en
Application granted granted Critical
Publication of CN101840352B publication Critical patent/CN101840352B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/30Monitoring
    • G06F11/34Recording or statistical evaluation of computer activity, e.g. of down time, of input/output operation ; Recording or statistical evaluation of user activity, e.g. usability assessment
    • G06F11/3466Performance evaluation by tracing or monitoring
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2201/00Indexing scheme relating to error detection, to error correction, and to monitoring
    • G06F2201/80Database-specific techniques

Landscapes

  • Engineering & Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Hardware Design (AREA)
  • Quality & Reliability (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The invention discloses a method and device for monitoring a database connection pool, which are used for tracking SQL sentences executed on database connection so as to provide a basis for accurately and rapidly realizing the problem positioning of abnormal conditions in the database connection pool. The monitoring method comprises the following steps of: acquiring database connection from the database connection pool; establishing object instances of JDBC interface realization for executing SQL sentences based on the database connection, and saving all the object instances and SQL sentence tracking information thereof established by the database connection according to variables and methods needed to be used for realizing SQL sentence tracking for public parameter definition inherited by the JDBC interface realization; in the process of executing the database operation by using the database connection, when monitoring an abnormal condition in the database connection pool, acquiring all the object instances established by the database connection; and aiming at each object instance, acquiring the SQL sentence tracking information of the object instance.

Description

A kind of method for supervising of database connection pool and device
Technical field
The present invention relates to the JAVA applied technical field, relate in particular to a kind of method for supervising and device of database connection pool.
Background technology
JAVA is by the make peace general name of JAVA platform of the JAVA program design language that Sun Microsystems company releases.JAVA programming language (be called for short JAVA language) is a kind of dynamic language of OO, distributed, healthy and strong safety, structure neutrality, transplantable, multithreading.(Virtual Machine, VM) (ApplicationProgramming Interface API) constitutes the JAVA platform with the JAVA application programming interfaces by the JAVA virtual machine.JAVAAPI provides the standard interface that is independent of operating system for the JAVA application program, JDBC (JAVA Data Base Connectivity wherein, the JAVA database connects) be to be used to carry out SQL (Structured Query Language, Structured Query Language (SQL)) the JAVA API of statement, JDBC adopts the class and the interface of JAVA language compilation to form by one group, can connect, send SQL statement and processing execution result with database.SQL is a kind of programming language of data base querying, is used for access data and inquiry, renewal and administrative relationships Database Systems.
In application system based on JAVA, To enterprises user's application system especially, database access is one of its core technology.Big, the problems such as response speed is slow, system stability is low, memory overflow of system resource overhead that exist when solving the frequent access database have been introduced Database Connection-Pool Technology in the application system.The basic thought of database connection pool is to set up one " Buffer Pool " for database connects.Database connection pool will be created the database connection of some and put into database connection pool when initialization, the quantity that the database of initial creation connects is determined that by the minimum linking number of setting the maximum number of connections of setting data storehouse connection pool is connected with the endless of database to prevent application system simultaneously.When needs are set up the database connection, only needing to take out from database connection pool a database connects, again database connection pool being put back in this database connection after finishing using gets final product, both avoided frequent foundation that database connects, closed the system resource overhead of being brought, made each database connect again to be able to efficient, safe multiplexing.
In the prior art, cache database connects in the database connection pool, can reduce system resource overhead, but can't monitor each database and connect performed database manipulation, in case professional time overlength or the storehouse operation of execution invalid data of using database to connect can cause database connection pool generation abnormal conditions, database connection pool can only capture the generation of abnormal conditions, but can't locate be by which professional which SQL statement of carrying out cause unusual.For fear of the system resource overhead that a large amount of daily records bring, also can not in daily record, write down all SQL statement of each professional execution, make a plurality of business of operation or the professional SQL statement of carrying out more for a long time, especially difficult at the positioning problems of abnormal conditions.
Summary of the invention
The embodiment of the invention provides a kind of method for supervising and device of database connection pool, in order to realizing database is connected the tracking of the SQL statement of carrying out, thereby provides the basis for the positioning problems of abnormal conditions in the fulfillment database connection pool accurately and rapidly.
A kind of method for supervising of database connection pool comprises:
Obtaining database from database connection pool connects;
Connect the object instance of creating the JAVA database connection JDBC interface realization class that is used for execution architecture query language SQL statement based on the database that gets access to, and realize that according to described JDBC interface the realization SQL statement of the common parameter class definition that class is inherited follows the tracks of variable and the method that needs use, preserve described database and connect all object instances and the SQL statement trace information of being created thereof;
Connect in the process of carrying out database manipulation at the database that use gets access to, monitor when abnormal conditions occurring in the database connection pool, obtain described database and connect all object instances of being created; And
At each object instance, obtain the SQL statement trace information of this object instance.
A kind of supervising device of database connection pool comprises:
Acquiring unit is used for obtaining database from database connection pool and connects;
Creating unit, be used for connecting the object instance of creating the JAVA database connection JDBC interface realization class that is used for execution architecture query language SQL statement based on the database that gets access to, and realize that according to described JDBC interface the realization SQL statement of the common parameter class definition that class is inherited follows the tracks of variable and the method that needs use, preserve described database and connect all object instances and the SQL statement trace information of being created thereof;
Monitoring unit, the database that is used for getting access in use connects the process of carrying out database manipulation, monitors when abnormal conditions occurring in the database connection pool, obtains described database and connects all object instances of being created;
Obtain the unit, be used for, obtain the SQL statement trace information of this object instance at each object instance.
The method for supervising of the database connection pool that the embodiment of the invention provides and device, each database of buffer memory connects SQL statement trace information relevant in the process of carrying out database manipulation in real time, when appearring in database connection pool, abnormal conditions obtain above-mentioned SQL statement trace information, thereby realize database is connected the tracking of the SQL statement of carrying out, the positioning problems that connects abnormal conditions in the process of carrying out database manipulation for fulfillment database accurately and rapidly provides the basis, improves the steadiness of database connection pool.
Other features and advantages of the present invention will be set forth in the following description, and, partly from instructions, become apparent, perhaps understand by implementing the present invention.Purpose of the present invention and other advantages can realize and obtain by specifically noted structure in the instructions of being write, claims and accompanying drawing.
Description of drawings
Fig. 1 is that the database connection pool inner classes after improving in the embodiment of the invention concerns synoptic diagram;
Fig. 2 is the structural representation of each the crucial inner classes of database connection pool after improving in the embodiment of the invention;
Fig. 3 creates the method flow diagram that database connects in the embodiment of the invention;
Fig. 4 is the method for supervising process flow diagram of database connection pool in the embodiment of the invention;
Fig. 5 is a method of creating the PoolPreparedStatement object instance in the embodiment of the invention;
Fig. 6 is the supervising device block diagram of database connection pool in the embodiment of the invention.
Embodiment
The embodiment of the invention provides the method for supervising and the device of the database connection pool in a kind of JAVA application program, in order to realization database is connected the tracking of the SQL statement of carrying out, thereby provide the basis for being positioned at the abnormal conditions that occur in the database connection pool in the JAVA application process accurately and rapidly.
Below in conjunction with Figure of description the preferred embodiments of the present invention are described, be to be understood that, preferred embodiment described herein only is used for description and interpretation the present invention, and be not used in qualification the present invention, and under the situation of not conflicting, embodiment and the feature among the embodiment among the present invention can make up mutually.
The inventor finds, in order to realize database is connected the tracking of the SQL statement of carrying out, thereby be accurate, the positioning problems of abnormal conditions provides the basis in the fulfillment database resource pool apace, improve the steadiness of database connection pool, need improve database connection pool, each database of buffer memory connects the SQL statement trace information in the process of carrying out database manipulation in real time, for example each database connects performed SQL statement and execution time thereof in the database connection pool, so that can be accurate when abnormal conditions take place, orient apace by which professional which SQL statement of carrying out cause unusual.
In the application system based on JAVA, JDBC is the JAVA API that is used to carry out SQL statement, and JDBC adopts the class and the interface of JAVA language compilation to form by one group.In the embodiment of the invention, use JDBC technology access database equally, the interface that provides based on JDBC realizes database is connected the tracking of the SQL statement of carrying out.
Database connection pool inner classes after the improvement concerns that synoptic diagram sees also Fig. 1 (JDBC standard database interface class is called for short the JDBC interface class in Fig. 1), describe below in conjunction with each inner classes and mutual relationship thereof in the database connection pool after 1 pair of improvement of Figure of description, wherein:
[1] StatementUtil: common parameter class, be used to define the variable and the method that realize that SQL statement tracking needs use, comprise Connection object instance under the JDBC standard database interface class Statement be database connections, Statement object instance, Statement object instance to begin to carry out database manipulation be time of SQL statement or the like, common parameter class StatementUtil is the base class of other inner Statement realization classes in the database connection pool after improving;
[2] PoolStatement: the inner Statement class that realizes of database connection pool, inherit common parameter class StatementUtil, and realize JDBC standard database interface class Statement, promptly PoolStatement is the JDBC interface realization class of JDBC standard database interface class Statement correspondence;
[3] PoolPreparedStatement: the inner PreparedStatement class that realizes of database connection pool, inherit the JDBC interface and realize class PoolStatement, and realize JDBC standard database interface class PreparedStatement (JDBC standard database interface class PreparedStatement inherits JDBC standard database interface class Statement), promptly PoolPreparedStatement is the JDBC interface realization class of JDBC standard database interface class PreparedStatement correspondence;
[4] PoolCallableStatement: the inner CallableStatement class that realizes of database connection pool, inherit the JDBC interface and realize class PoolPreparedStatement, and realize JDBC standard database interface class CallableStatement (JDBC standard database interface class CallableStatement inherits JDBC standard database interface class PreparedStatement), promptly PoolCallableStatement is the JDBC interface realization class of JDBC standard database interface class CallableStatement correspondence;
[5] PoolConnection: the inner definition of database connection pool Connection interface class, the method of database join dependency information is obtained in definition, for example obtain the method that database connects the place database connection pool, obtain the method for the creation-time of database connection;
[6] PoolConnectionImpl: the inner Connection of database connection pool realizes class, realize the inner definition of JDBC standard database interface class Connection and database connection pool Connection interface class PoolConnection, the PoolConnectionImpl object instance of buffer memory some in the database connection pool, promptly PoolConnectionImpl is the JDBC interface realization class of JDBC standard database interface class Connection correspondence;
[7] getConection (): the basic skills in the database connection pool, can obtain the database connection by calling this method, in the database connection pool after the improvement, what this method was returned is the PoolConnectionImpl object instance, because PoolConnectionImpl has realized JDBC normal data bank interface, therefore concerning business, still use the method for Connection object instance;
[8] createStatement (): the method for JDBC standard database interface class Connection definition, can obtain the Statement object instance by calling this method, and then by a series of manner of execution fulfillment database operations;
[9] prepareStatement (): the method for JDBC standard database interface class Connection definition, can obtain the PreparedStatement object instance by calling this method, and then by a series of manner of execution fulfillment database operations;
[10] prepareCall (): the method for JDBC standard database interface class Connection definition, can obtain the CallableStatement object instance by calling this method, and then by a series of manner of execution fulfillment database operations.
In the database connection pool after the improvement structural representation of each crucial inner classes as shown in Figure 2, the key element to several crucial inner classes in the database connection pool after improving describes below.
Before this, the several key elements to Database Connection Pool class ConnectionPoolImpl in the prior art describe:
1) variable managed:ArrayList type, the database that is used for the cache database connection pool connects, i.e. the Connection object instance; Accordingly, the PoolConnectionImpl object instance of buffer memory some in the embodiment of the invention;
2) newPooledConnection (): this method is used to create database and connects, return PoolConnectionImpl object instance (being equal to the Connection object instance in the common connection pool), database connection pool connects the database of creating puts into variable managed buffer memory;
3) getConection (): this method is used to obtain database and connects for professional use, returns PoolConnectionImpl object instance (being equal to the Connection object instance in the common connection pool).
Realize at the existing database connection pool on the basis of class ConnectionPoolImpl, inner Connection in the database connection pool after improving realized that the key element of class PoolConnectionImpl describes:
1) variable conn:Connection object instance is used to finish various database manipulations;
2) variable pool:ConnectionPoolImpl object instance is used to preserve this database and connects affiliated database connection pool object;
3) statementSet:Set object instance, be used to preserve database and connect the Statement object instance of being created, also be the object instance of StatementUtil subclass, connect SQL statement trace informations such as the SQL statement carried out and execution time so that therefrom obtain this database;
4) variable createTime: the creation-time that database connects;
5) variable lastCheckinTime: database connects be used last time the time that discharges afterwards;
Whether 6) variable lastCheckoutTime: database connects the time that was acquired last time, can be released in conjunction with service time and this use that lastCheckinTime specified data storehouse connects;
7) addStatement (Statement): add in the statementSet set variable going into to join the Statement object instance, database calls this method when connecting establishment Statement object instance;
8) removeAll Statements (): empty all the Statement object instances among the statementSet, database connects this method of calling when being released;
9) poolStatement (Statement): be used to create the PoolStatement object instance, ginseng is gone in the conduct of Statement object instance, and is kept in the PoolStatement object instance, and this method is returned the PoolStatement object instance of establishment;
10) poolPreparedStatement (PreparedStatement): be used to create the PoolPreparedStatement object instance, the PreparedStatement object instance is as going into ginseng, and be kept in the PoolPreparedStatement object instance, this method is returned the PoolPreparedStatement object instance of establishment;
11) poolCallableStatement (CallableStatement): be used to create the PoolCallableStatement object instance, the CallableStatement object instance is as going into ginseng, and be kept in the PoolCallableStatement object instance, this method is returned the PoolCallableStatement object instance of establishment;
12) createStatement (): realize the method in the Connection interface, be used to create the Statement object instance, and with it as going into to join call method poolStatement () to create the PoolStatement object instance, call method addStatement () simultaneously finally returns the PoolStatement object instance of establishment;
13) prepareStatement (): realize the method in the Connection interface, be used to create the PreparedStatement object instance, and with it as going into to join call method poolPreparedStatement () to create the PoolPreparedStatement object instance, call method addStatement () simultaneously finally returns the PoolPreparedStatement object instance of establishment;
14) prepareCall (): realize the method in the Connection interface, be used to create the CallableStatement object instance, and with it as going into to join call method poolCallableStatement () to create the PoolCallableStatement object instance, call method addStatement () simultaneously finally returns the PoolCallableStatement object instance of establishment.
At last, the key element to common parameter class StatementUtil in the database connection pool after improving describes:
1) the PoolConnectionImpl object instance under the variable pooledConnection:Statement object instance;
2) variable statement: the Statement object instance of this object instance association;
3) variable startExecTime:Statement object instance begins to carry out the time of database manipulation;
4) variable putedParameters:List type, the parameter that is used to preserve the Statement object instance;
5) variable executeFlag: execute flag, wherein the executeFlag value is that 0 expression is not carried out, the executeFlag value is that commonSql is carried out in 1 expression, and the executeFlag value is that preparedSql is carried out in 2 expressions, and the executeFlag value is that batchSql is carried out in 3 expressions;
6) batchSql:List type, the SQL statement when being used to preserve executeBatch;
7) preparedSql: be used to preserve the SQL statement that the PreparedStatement object instance is carried out;
8) commonSql: be used to preserve the SQL statement that the Statement object instance is carried out;
9) StatementUtil (): the constructed fuction of StatementUtil object instance, go into ginseng for PoolConnectionImpl object instance and Statement object instance, be used for initializing variable pooledConnection and variable statement;
10) addParameter (): the parameter of importing into is added among the variable putedParameters;
11) setExecuteFlag (): executeFlag sign is set, and which kind of SQL statement what be used to distinguish current execution is;
12) appandBatchSQL (): SQL statement is added among the batchSql, and executeFlag used this method at 3 o'clock;
13) setPreparedSql (): preparedSql is set, and executeFlag used this method at 2 o'clock;
14) setCommonSql (): commonSql is set, and executeFlag used this method at 1 o'clock;
15) isExecTimeout (): judge whether execution is overtime, go into ginseng and be time-out time;
16) executeOver (): call this method after carrying out end, empty executeFlag execute flag position (be set to 0, i.e. expression is carried out) and startExecTime.
Below, elaborate the realization principle of the database connection pool after the improvement, mainly comprise the content of three aspects:
(1) realization of JDBC standard database interface class
JDBC standard database interface class comprises Connection, Statement, PreparedStatement, CallableStatement, wherein the Connection definition database connects, and Statement, PreparedStatement, CallableStatement define variable and the method that is used to carry out SQL statement respectively.By improvement to database connection pool, JDBC standard database interface class Connection, Statement, PreparedStatement, the respectively corresponding JDBC interface of CallableStatement is realized class PoolConnectionImpl, PoolStatement, PoolPreparedStatement and PoolCallableStatement, be that Connection is corresponding with PoolConnectionImpl, Statement is corresponding with PoolStatement, PreparedStatement is corresponding with PoolPreparedStatement, and CallableStatement is corresponding with PoolCallableStatement.
Above-mentioned JDBC interface realizes that class both can be used as JDBC standard database interface class and used, can increase personalized variable and method again, that is to say, buffer memory is the object instance of the JDBC interface realization class PoolConnectionImpl of JDBC standard database interface class Connection correspondence in the database connection pool, it is actual when business is obtained database and connected that what return is the PoolConnectionImpl object instance, above-mentioned improvement is transparent to business, and is professional as usual according to the connection of JDBC normal data bank interface use database.In like manner, professional by calling the method createStatement () of JDBC standard database interface class Connection definition, prepareStatement (), prepareCall () obtains Statement, PreparedStatement, during the CallableStatement object instance, the JDBC interface of the actual above-mentioned JDBC standard database interface class correspondence of returning of PoolConnectionImpl object instance is realized the object instance of class, be PoolStatement, PoolPreparedStatement, the PoolCallableStatement object instance, above-mentioned improvement is transparent equally concerning business, and business is carried out database manipulation according to JDBC normal data bank interface as usual.
(2) expansion of JDBC standard database interface class
The expanded body of JDBC standard database interface class has been increased now the content of two aspects: attribute and succession.Increasing attribute is that above-mentioned JDBC interface is realized having increased variable in the class, be used to preserve corresponding object instance and relevant information thereof, for example the JDBC interface is realized having increased variable conn (being used to preserve the Connection object instance) among the class PoolConnectionImpl, pool (being used to preserve the ConnectionPoolImpl object instance) or the like, the JDBC interface is realized having increased variable preparedStatement (being used to preserve the PreparedStatement object instance) among the class PoolPreparedStatement, and the JDBC interface is realized having increased variable callableStatement (being used to preserve the CallableStatement object instance) among the class PoolCallableStatement.Increasing succession is that the JDBC interface is realized class PoolStatement, PoolPreparedStatement, PoolCallableStatement realizes JDBC standard database interface class Statement, PreparedStatement, in the time of CallableStatement, inherit common parameter class StatementUtil, common parameter class StatementUtil has defined variable and the method that SQL statement is followed the tracks of needs use that realize, comprise that the Connection object instance under the JDBC standard database interface class Statement is that database connects, the Statement object instance, the Statement object instance begins time of carrying out database manipulation or the like, and inner Statement realizes that class can obtain to realize required variable and the method for SQL statement tracking by inheriting common parameter class StatementUtil.
(3) realization of the method for JDBC standard database interface class definition
Each JDBC interface realization class is called the method for corresponding JDBC standard database interface class definition when realizing JDBC normal data bank interface, carried out particular procedure for the tracking that realizes SQL statement simultaneously, final still by the operation of JDBC normal data bank interface fulfillment database, relevant treatment such as buffer memory have just additionally been increased to SQL statement, the execution flow process that realizes the method prepareStatement () among the class PoolConnectionImpl as the JDBC interface is: call conn.prepareStatement (sql) earlier, again the PreparedStatement object instance that returns is created the PoolPreparedStatement object instance with self as parameter, preserve SQL statement then, return the PoolPreparedStatement object instance of establishment at last.The realization of additive method and the realization of said method are similar, specifically repeat no more.
Based on the database connection pool after improving, the method for supervising of the database connection pool that the embodiment of the invention is provided is elaborated.
The embodiment of the invention at first provides a kind of method that database connects of creating in database connection pool, realization flow figure comprises the steps: as shown in Figure 3
S301, initializing variable managed, variable managed are used for cache database and connect;
S302, call method newPooledConnection () are that database connects conn to create the Connection object instance;
S303, database is connected conn and database connection pool object call the constructed fuction of PoolConnectionImpl as going into ginseng, creating the PoolConnectionImpl object instance is that database connects pConn;
S304, the database of creating is connected pConn add buffer memory among the variable managed to;
The database that S305, judgement are created connects pConn and whether reaches predefined maximum number of connections, if then flow process finishes, and if not, then returns step S302.
The embodiment of the invention provides a kind of method for supervising of database connection pool, as shown in Figure 4, comprises the steps:
S401, to obtain the PoolConnectionImpl object instance from database connection pool be that database connects pconn;
In concrete the enforcement, obtaining the PoolConnectionImpl object instance by call method getConection () is that database connects pconn, method getConection () returns the PoolConnectionImpl object instance, and it is that database connects a variable among the pconn that database connects conn.
S402, connect pconn based on the database that gets access to and create the object instance that the JDBC interface that is used to carry out SQL statement is realized class;
In concrete the enforcement, the described JDBC interface that is used to carry out SQL statement realizes that class comprises PoolStatement, PoolPreparedStatement and PoolCallableStatement, and corresponding object instance comprises PoolStatement object instance, PoolPreparedStatement object instance and PoolCallableStatement object instance; The JDBC interface that database connects that pconn created is used to carry out SQL statement realizes that the object instance of class can be PoolStatement object instance, PoolPreparedStatement object instance, PoolCallableStatement object instance one of them or combination in any;
In the embodiment of the invention, realization flow with establishment PoolPreparedStatement object instance ppstat is that example describes, specifically see also Fig. 5, the realization flow of creating PoolStatement object instance and PoolCallableStatement object instance is similar with the realization flow of creating the PoolPreparedStatement object instance, repeats no more.
S403, realize that according to the JDBC interface that is used to carry out SQL statement the realization SQL statement of the common parameter class definition that class is inherited follows the tracks of variable and the method that needs use, preserve database and connect all object instances and the SQL statement trace information thereof that pconn created;
Describe for example, suppose to realize that based on the described JDBC interface of the database connection pconn establishment that gets access to the object instance of class is PoolPreparedStatement object instance ppstat among the S402, then in the concrete enforcement of S402, by calling the method setPreparedSql () of PoolPreparedStatement object instance ppstat, preserve the SQL statement that the PreparedStatement object instance is carried out; Add PoolPreparedStatement object instance ppstat to statementSet set variable by call method addStatement ().
S404, connect in the process that pconn carries out database manipulation, monitor when abnormal conditions occurring in the database connection pool, obtain this database and connect all object instances of being created at database that use gets access to;
In concrete the enforcement, the database connection pool monitor task monitors when abnormal conditions occurring in the database connection pool, obtain statementSet set variable by call method getStatementSet (), this database of storage connects all object instances of being created in the statementSet set variable;
S405, at each object instance, obtain the SQL statement trace information of this object instance;
In concrete the enforcement, at each object instance in the statementSet set variable, by method getSQLString () and the getExecTime () that calls each object instance, obtain the SQL statement trace information of this object instance, the SQL statement trace information comprises information such as SQL statement that database connect to be carried out and execution time, wherein, method getSQLString () and getExecTime () are defined by common parameter class StatementUtil.
So far, realized the monitoring to database connection pool, in concrete the enforcement, this method also comprises the steps:
When discharging database connection pconn, this database that empties preservation connects all object instances of being created, discharges database connection pconn and is meant that database is connected pconn to be put back in the database connection pool.
Further, carry out the positioning problems of abnormal conditions for the ease of the user, this method also can comprise the steps:
The SQL statement trace information of each object instance of obtaining is printed in the journal file, carries out the positioning problems of abnormal conditions for the user.
Create the method for PoolPreparedStatement object instance, as shown in Figure 5, comprise the steps:
S501, definition JDBC interface are realized the variable ppstat of class PoolPreparedStatement, and assignment is null;
S502, call database and connect the method prepareStatement () of conn definition to create PreparedStatement object instance pstat;
S503, database is connected pconn and PreparedStatement object instance pstat call the constructed fuction of PoolPreparedStatement, create PoolPreparedStatement object instance ppstat as going into ginseng.
Based on same technical conceive, the embodiment of the invention provides a kind of supervising device of database connection pool, as figure, comprising:
Acquiring unit 601 is used for obtaining database from database connection pool and connects;
Creating unit 602, be used for connecting and create the object instance that the JDBC interface that is used to carry out SQL statement is realized class based on the database that gets access to, and realize that according to this JDBC interface the realization SQL statement of the common parameter class definition that class is inherited follows the tracks of variable and the method that needs use, preserve this database and connect all object instances and the SQL statement trace information of being created thereof;
Monitoring unit 603, the database that is used for getting access in use connects the process of carrying out database manipulation, monitors when abnormal conditions occurring in the database connection pool, obtains this database and connects all object instances of being created;
Obtain unit 604, be used for, obtain the SQL statement trace information of this object instance at each object instance.
In concrete the enforcement, the supervising device of this database connection pool also can comprise:
Empty unit 605, be used for when discharging this database connection, this database that empties preservation connects all object instances of being created.
In concrete the enforcement, the user carries out the positioning problems of abnormal conditions for convenience, and the supervising device of this database connection pool also can comprise:
Print unit 606, the SQL statement trace information that is used for each object instance that will obtain is printed on journal file, carries out the positioning problems of abnormal conditions for the user.
The method for supervising of the database connection pool that the embodiment of the invention provides and device, each database of buffer memory connects SQL statement trace information relevant in the process of carrying out database manipulation in real time, when appearring in database connection pool, abnormal conditions obtain above-mentioned SQL statement trace information, thereby realize database is connected the tracking of the SQL statement of carrying out, the positioning problems that connects abnormal conditions in the process of carrying out database manipulation for fulfillment database accurately and rapidly provides the basis, improves the steadiness of database connection pool.
It will be understood by those skilled in the art that embodiments of the invention can be provided as method, device or computer program.Therefore, the present invention can adopt complete hardware embodiment, complete software implementation example or in conjunction with the form of the embodiment of software and hardware aspect.And the present invention can adopt the form that goes up the computer program of implementing in one or more computer-usable storage medium (including but not limited to magnetic disk memory, CD-ROM, optical memory etc.) that wherein include computer usable program code.
The present invention is that reference is described according to the process flow diagram and/or the block scheme of method, device and the computer program of the embodiment of the invention.Should understand can be by the flow process in each flow process in computer program instructions realization flow figure and/or the block scheme and/or square frame and process flow diagram and/or the block scheme and/or the combination of square frame.Can provide these computer program instructions to the processor of multi-purpose computer, special purpose computer, Embedded Processor or other programmable data processing device to produce a machine, make the instruction of carrying out by the processor of computing machine or other programmable data processing device produce to be used for the device of the function that is implemented in flow process of process flow diagram or a plurality of flow process and/or square frame of block scheme or a plurality of square frame appointments.
These computer program instructions also can be stored in energy vectoring computer or the computer-readable memory of other programmable data processing device with ad hoc fashion work, make the instruction that is stored in this computer-readable memory produce the manufacture that comprises command device, this command device is implemented in the function of appointment in flow process of process flow diagram or a plurality of flow process and/or square frame of block scheme or a plurality of square frame.
These computer program instructions also can be loaded on computing machine or other programmable data processing device, make on computing machine or other programmable devices and to carry out the sequence of operations step producing computer implemented processing, thereby the instruction of carrying out on computing machine or other programmable devices is provided for being implemented in the step of the function of appointment in flow process of process flow diagram or a plurality of flow process and/or square frame of block scheme or a plurality of square frame.
Obviously, those skilled in the art can carry out various changes and modification to the present invention and not break away from the spirit and scope of the present invention.Like this, if of the present invention these are revised and modification belongs within the scope of claim of the present invention and equivalent technologies thereof, then the present invention also is intended to comprise these changes and modification interior.

Claims (10)

1. the method for supervising of a database connection pool is characterized in that, comprising:
Obtaining database from database connection pool connects;
Connect the object instance of creating the JAVA database connection JDBC interface realization class that is used for execution architecture query language SQL statement based on the database that gets access to, and realize that according to described JDBC interface the realization SQL statement of the common parameter class definition that class is inherited follows the tracks of variable and the method that needs use, preserve described database and connect all object instances and the SQL statement trace information of being created thereof;
Connect in the process of carrying out database manipulation at the database that use gets access to, monitor when abnormal conditions occurring in the database connection pool, obtain described database and connect all object instances of being created; And
At each object instance, obtain the SQL statement trace information of this object instance.
2. the method for claim 1 is characterized in that, also comprises:
When the described database of release connected, this database that empties preservation connected all object instances of being created.
3. the method for claim 1 is characterized in that, the SQL statement trace information of described object instance comprises SQL statement and the execution time that this object instance is carried out.
4. as claim 1,2 or 3 described methods, it is characterized in that, also comprise:
The SQL statement trace information of each object instance of obtaining is printed in the journal file, carries out the positioning problems of abnormal conditions for the user.
5. as claim 1,2 or 3 described methods, it is characterized in that, the described JDBC interface realization class that is used to carry out SQL statement specifically comprises: the JDBC interface of realizing the JDBC interface realization class PoolStatement of JDBC standard database interface class Statement, the JDBC interface realization class PoolPreparedStatement that realizes JDBC standard database interface class PreparedStatement and realization JDBC standard database interface class CallableStatement is realized class PoolCallableStatement.
6. method as claimed in claim 5 is characterized in that, creates the method for PoolPreparedStatement object instance, specifically comprises:
Create the PreparedStatement object instance;
The database connection and the PreparedStatement object instance that get access to are called the constructed fuction of PoolPreparedStatement as going into ginseng, create the PoolPreparedStatement object instance.
7. as claim 1,2 or 3 described methods, it is characterized in that, described database is connected to the PoolConnectionImpl object instance, described PoolConnectionImpl realizes class for the JDBC interface of realizing JDBC standard database interface class Connection, and in database connection pool, create the method that database connects, specifically comprise:
Be used for the variable that cache database connects in the connection pool of initialization data storehouse;
Establishment Connection object instance calls the constructed fuction of PoolConnectionImpl with Connection object instance and database connection pool object as going into ginseng, and create database and connect, and with database connection adding to buffer memory in the described variable of creating;
When the quantity of the database connection of creating reaches predefined maximum number of connections, stop the establishment that database connects.
8. the supervising device of a database connection pool is characterized in that, comprising:
Acquiring unit is used for obtaining database from database connection pool and connects;
Creating unit, be used for connecting the object instance of creating the JAVA database connection JDBC interface realization class that is used for execution architecture query language SQL statement based on the database that gets access to, and realize that according to described JDBC interface the realization SQL statement of the common parameter class definition that class is inherited follows the tracks of variable and the method that needs use, preserve described database and connect all object instances and the SQL statement trace information of being created thereof;
Monitoring unit, the database that is used for getting access in use connects the process of carrying out database manipulation, monitors when abnormal conditions occurring in the database connection pool, obtains described database and connects all object instances of being created;
Obtain the unit, be used for, obtain the SQL statement trace information of this object instance at each object instance.
9. device as claimed in claim 8 is characterized in that, also comprises:
Empty the unit, be used for when the described database of release connects, the described database that empties preservation connects all object instances of being created.
10. install as claimed in claim 8 or 9, it is characterized in that, also comprise:
Print unit, the SQL statement trace information that is used for each object instance that will obtain is printed on journal file, carries out the positioning problems of abnormal conditions for the user.
CN201010160673.5A 2010-04-29 2010-04-29 Method and device for monitoring database connection pool Active CN101840352B (en)

Priority Applications (2)

Application Number Priority Date Filing Date Title
CN201010160673.5A CN101840352B (en) 2010-04-29 2010-04-29 Method and device for monitoring database connection pool
PCT/CN2010/077270 WO2011134233A1 (en) 2010-04-29 2010-09-25 Method and device for monitoring database connection pool

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201010160673.5A CN101840352B (en) 2010-04-29 2010-04-29 Method and device for monitoring database connection pool

Publications (2)

Publication Number Publication Date
CN101840352A true CN101840352A (en) 2010-09-22
CN101840352B CN101840352B (en) 2014-09-10

Family

ID=42743738

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201010160673.5A Active CN101840352B (en) 2010-04-29 2010-04-29 Method and device for monitoring database connection pool

Country Status (2)

Country Link
CN (1) CN101840352B (en)
WO (1) WO2011134233A1 (en)

Cited By (21)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101980207A (en) * 2010-11-09 2011-02-23 中国电信股份有限公司 Method and system for implementing database access
CN102110162A (en) * 2011-02-24 2011-06-29 北京中电普华信息技术有限公司 Method and device for realizing monitoring on SQL (structured query language) database
WO2011134233A1 (en) * 2010-04-29 2011-11-03 中兴通讯股份有限公司 Method and device for monitoring database connection pool
CN102385628A (en) * 2011-11-14 2012-03-21 北京锐安科技有限公司 Java data base connectivity (JDBC)-based data distributed processing method
CN102594728A (en) * 2012-02-09 2012-07-18 苏州阔地网络科技有限公司 Distributed instant communication method and system
CN102594727A (en) * 2012-02-07 2012-07-18 苏州阔地网络科技有限公司 Distributed instant communication system and communication method thereof
CN104361000A (en) * 2014-09-24 2015-02-18 广东电网有限责任公司佛山供电局 Access method and system for relational database based on self-built database connection pool
CN104484452A (en) * 2014-12-25 2015-04-01 广东电子工业研究院有限公司 Connection reusing and unified management and control method of multi-element isomerism relation database
CN104778185A (en) * 2014-01-15 2015-07-15 中国移动通信集团北京有限公司 Determination method for abnormal SQL (structured query language) statement and server
CN105302565A (en) * 2015-11-10 2016-02-03 河海大学 Java-based data persistence assembly with built-in connection pool management function
CN105426285A (en) * 2015-10-28 2016-03-23 联动优势科技有限公司 Method and apparatus for monitoring and managing database connection pool
CN107748632A (en) * 2017-09-28 2018-03-02 努比亚技术有限公司 Freeze screen monitoring method, mobile terminal and computer-readable recording medium
CN108108479A (en) * 2018-01-04 2018-06-01 山东中创软件商用中间件股份有限公司 A kind of database connecting detection method, system, equipment and computer media
CN109213789A (en) * 2017-07-07 2019-01-15 北京京东尚科信息技术有限公司 A kind of analysis method and device about business SQL
CN109739486A (en) * 2019-01-03 2019-05-10 深圳英飞拓科技股份有限公司 Multi-data source database manipulation implementation method and device based on JdbcTemplate
CN110209688A (en) * 2019-04-16 2019-09-06 中国平安人寿保险股份有限公司 Structured query sentence localization method, device, computer installation and storage medium
CN111309507A (en) * 2020-02-13 2020-06-19 支付宝(杭州)信息技术有限公司 Memory leak detection method and device and machine-readable storage medium
CN111767187A (en) * 2020-05-19 2020-10-13 中国建设银行股份有限公司 Method for monitoring JDBC connection pool state and related equipment
CN112988401A (en) * 2021-05-07 2021-06-18 北京轻松筹信息技术有限公司 Method and device for collecting information in process and electronic equipment
CN113986736A (en) * 2021-10-29 2022-01-28 重庆富民银行股份有限公司 Slow SQL monitoring system and method based on JAVA proxy and bytecode enhancement
CN116737818A (en) * 2023-08-15 2023-09-12 浩鲸云计算科技股份有限公司 Connection leakage detection method and system for draid database connection pool

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112925841B (en) * 2021-03-26 2022-11-08 瀚高基础软件股份有限公司 Distributed JDBC implementation method, device and computer-readable storage medium

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1567301A (en) * 2003-06-23 2005-01-19 华为技术有限公司 Method and apparatus for accessing database
US20070083525A1 (en) * 2005-10-11 2007-04-12 Rahul Srivastava JDBC debugging enhancements
CN101339559A (en) * 2008-07-18 2009-01-07 北京航空航天大学 Long lasting implementing method for data
JP2009110439A (en) * 2007-10-31 2009-05-21 Nec Corp Database access system, database access method and program

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101226497B (en) * 2007-12-10 2011-06-22 金蝶软件(中国)有限公司 Application program monitoring system and monitoring method
CN101840352B (en) * 2010-04-29 2014-09-10 中兴通讯股份有限公司 Method and device for monitoring database connection pool

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1567301A (en) * 2003-06-23 2005-01-19 华为技术有限公司 Method and apparatus for accessing database
US20070083525A1 (en) * 2005-10-11 2007-04-12 Rahul Srivastava JDBC debugging enhancements
JP2009110439A (en) * 2007-10-31 2009-05-21 Nec Corp Database access system, database access method and program
CN101339559A (en) * 2008-07-18 2009-01-07 北京航空航天大学 Long lasting implementing method for data

Cited By (30)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2011134233A1 (en) * 2010-04-29 2011-11-03 中兴通讯股份有限公司 Method and device for monitoring database connection pool
CN101980207A (en) * 2010-11-09 2011-02-23 中国电信股份有限公司 Method and system for implementing database access
CN102110162A (en) * 2011-02-24 2011-06-29 北京中电普华信息技术有限公司 Method and device for realizing monitoring on SQL (structured query language) database
CN102110162B (en) * 2011-02-24 2013-03-20 国家电网公司 Method and device for realizing monitoring on SQL (structured query language) database
CN102385628A (en) * 2011-11-14 2012-03-21 北京锐安科技有限公司 Java data base connectivity (JDBC)-based data distributed processing method
CN102385628B (en) * 2011-11-14 2015-05-13 北京锐安科技有限公司 Java data base connectivity (JDBC)-based data distributed processing method
CN102594727A (en) * 2012-02-07 2012-07-18 苏州阔地网络科技有限公司 Distributed instant communication system and communication method thereof
CN102594728A (en) * 2012-02-09 2012-07-18 苏州阔地网络科技有限公司 Distributed instant communication method and system
CN104778185B (en) * 2014-01-15 2018-01-30 中国移动通信集团北京有限公司 Anomaly sxtructure query language SQL statement determines method and server
CN104778185A (en) * 2014-01-15 2015-07-15 中国移动通信集团北京有限公司 Determination method for abnormal SQL (structured query language) statement and server
CN104361000A (en) * 2014-09-24 2015-02-18 广东电网有限责任公司佛山供电局 Access method and system for relational database based on self-built database connection pool
CN104484452A (en) * 2014-12-25 2015-04-01 广东电子工业研究院有限公司 Connection reusing and unified management and control method of multi-element isomerism relation database
CN105426285A (en) * 2015-10-28 2016-03-23 联动优势科技有限公司 Method and apparatus for monitoring and managing database connection pool
CN105426285B (en) * 2015-10-28 2019-01-18 联动优势科技有限公司 The method and apparatus of database connection pool monitoring and management
CN105302565A (en) * 2015-11-10 2016-02-03 河海大学 Java-based data persistence assembly with built-in connection pool management function
CN109213789A (en) * 2017-07-07 2019-01-15 北京京东尚科信息技术有限公司 A kind of analysis method and device about business SQL
CN107748632A (en) * 2017-09-28 2018-03-02 努比亚技术有限公司 Freeze screen monitoring method, mobile terminal and computer-readable recording medium
CN107748632B (en) * 2017-09-28 2021-11-02 努比亚技术有限公司 Screen freezing monitoring method, mobile terminal and computer readable storage medium
CN108108479A (en) * 2018-01-04 2018-06-01 山东中创软件商用中间件股份有限公司 A kind of database connecting detection method, system, equipment and computer media
CN109739486A (en) * 2019-01-03 2019-05-10 深圳英飞拓科技股份有限公司 Multi-data source database manipulation implementation method and device based on JdbcTemplate
CN110209688B (en) * 2019-04-16 2023-08-18 中国平安人寿保险股份有限公司 Structured query statement positioning method, device, computer device and storage medium
CN110209688A (en) * 2019-04-16 2019-09-06 中国平安人寿保险股份有限公司 Structured query sentence localization method, device, computer installation and storage medium
CN111309507A (en) * 2020-02-13 2020-06-19 支付宝(杭州)信息技术有限公司 Memory leak detection method and device and machine-readable storage medium
CN111309507B (en) * 2020-02-13 2022-05-10 支付宝(杭州)信息技术有限公司 Memory leak detection method and device and machine-readable storage medium
CN111767187A (en) * 2020-05-19 2020-10-13 中国建设银行股份有限公司 Method for monitoring JDBC connection pool state and related equipment
CN111767187B (en) * 2020-05-19 2023-11-14 中国建设银行股份有限公司 Method for monitoring JDBC connection pool state and related equipment
CN112988401A (en) * 2021-05-07 2021-06-18 北京轻松筹信息技术有限公司 Method and device for collecting information in process and electronic equipment
CN113986736A (en) * 2021-10-29 2022-01-28 重庆富民银行股份有限公司 Slow SQL monitoring system and method based on JAVA proxy and bytecode enhancement
CN116737818A (en) * 2023-08-15 2023-09-12 浩鲸云计算科技股份有限公司 Connection leakage detection method and system for draid database connection pool
CN116737818B (en) * 2023-08-15 2023-12-22 浩鲸云计算科技股份有限公司 Connection leakage detection method and system for draid database connection pool

Also Published As

Publication number Publication date
CN101840352B (en) 2014-09-10
WO2011134233A1 (en) 2011-11-03

Similar Documents

Publication Publication Date Title
CN101840352B (en) Method and device for monitoring database connection pool
CN107391653B (en) Distributed NewSQL database system and picture data storage method
US8095570B2 (en) Decorated model architecture for efficient model-driven application development
EP2176763B1 (en) Memory transaction grouping
US20110185359A1 (en) Determining A Conflict in Accessing Shared Resources Using a Reduced Number of Cycles
CN104281906A (en) Process engine achieving method and system in service process
US9052972B2 (en) Determining the processing order of a plurality of events
CN101645020A (en) Virtual operating system creation method
CN102054034A (en) Implementation method for business basic data persistence of enterprise information system
US9535687B2 (en) Audited builds based upon separate class dependency records
CN109933606B (en) Database modification method, device, equipment and storage medium
CN101689154A (en) Leveraging transactional memory hardware to accelerate virtualization and emulation
CN104503989B (en) A method of it completing heterogeneous database and collects
CN109359038A (en) One kind realizing configurable test system, implementation method and equipment based on Qt and Lua combination
CN103400074A (en) Method and device for detecting hidden processes
CN104317723B (en) Method and system for tracking running information of drive program
Chaki et al. The ComFoRT reasoning framework
CN112130849B (en) Code automatic generation method and device
CN110941422B (en) Code automatic generation method, code generator and readable storage medium
CN105573763A (en) Embedded system modeling method supporting RTOS
CN114003353A (en) Concurrent mechanism-based autonomous transaction implementation method, system and application
EP2176761A1 (en) Object model for transactional memory
TWI610241B (en) Durable program execution
US11816023B1 (en) Test conflict guard for parallel software testing
US20230110270A1 (en) Generic factory class

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
C14 Grant of patent or utility model
GR01 Patent grant
C41 Transfer of patent application or patent right or utility model
TR01 Transfer of patent right

Effective date of registration: 20161019

Address after: 100000 Beijing, Jiuxianqiao, North Road, a number of hospital electronic city.IT Industrial Park, building 204, building 10

Patentee after: Beijing CIIC Runbang Technology Co. Ltd.

Address before: 518057 Nanshan District Guangdong high tech Industrial Park, South Road, science and technology, ZTE building, Ministry of Justice

Patentee before: ZTE Corporation