A method, apparatus, device, and storage medium for determining SQL information.
By receiving binding request messages and loading the target startup class, and by using ASM-enhanced Java interfaces to intercept SQL and reflectively load the connection pool class, the problem of non-intrusive acquisition of database SQL execution and connection pool status is solved, enabling real-time, efficient diagnostic analysis and business stability.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-03-14
- Publication Date
- 2026-03-06
AI Technical Summary
Existing technologies cannot obtain the SQL execution status and database connection pool status of the database without intruding on business code.
By receiving the binding request message sent by the second server, the target startup class is loaded, and the SQL information, including SQL execution indicator data and database connection pool indicator data, is determined using the target startup class. The SQL interface of ASM-enhanced Java is used for interception, and the connection pool status is obtained by loading the connection pool class through reflection.
It enables non-intrusive acquisition of SQL execution status and database connection pool status, supports real-time information acquisition during application operation, improves the efficiency and convenience of business system problem diagnosis and analysis, and ensures business continuity and stability.
Smart Images

Figure CN116244149B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and in particular to a method, apparatus, device and storage medium for determining SQL information. Background Technology
[0002] To ensure the continuity and stability of Java applications, it is necessary to obtain the execution status of the Structured Query Language (SQL) database and the status of the database connection pool in real time during the operation of the Java application.
[0003] However, existing technologies cannot obtain the SQL execution status and database connection pool status of the database without intruding on business logic. Therefore, how to obtain the SQL execution status and database connection pool status of the database without intrusion has become an urgent technical problem to be solved. Summary of the Invention
[0004] This application provides a method, apparatus, device, and storage medium for determining SQL information, which can non-intrusively obtain the SQL execution status of the database and the status of the database connection pool.
[0005] In a first aspect, this application provides a method for determining SQL information, applied to a first server, the method comprising:
[0006] Receive a binding request message sent by a second server, the binding request message including a target process identifier;
[0007] Load the target startup class based on the target process identifier;
[0008] The target startup class is used to determine the Structured Query Language (SQL) information;
[0009] The SQL information is sent to the second server.
[0010] In one possible implementation, determining the SQL information based on the target startup class includes:
[0011] Receive indication information sent by the second server, the indication information being used to indicate whether to obtain SQL execution indicator data or database connection pool indicator data;
[0012] Based on the indicated information, the SQL information is determined through the target startup class.
[0013] In one possible implementation, the indication information is used to indicate the acquisition of SQL execution indicator data, and the indication information includes SQL interception parameters, which include the target SQL and the SQL interception period.
[0014] The step of determining the SQL information based on the indication information and the target startup class includes:
[0015] The enhanced interface is loaded through the target startup class;
[0016] The enhanced interface is used to intercept the target SQL during the SQL interception period to obtain the SQL information, which includes the input parameters, output parameters, and execution time of the target SQL.
[0017] In one possible implementation, the indication information is used to indicate the acquisition of database connection pool indicator data, and the indication information includes the database connection pool interception period;
[0018] The step of determining the SQL information based on the indication information and the target startup class includes:
[0019] The loading class of the database connection pool is obtained through the target startup class;
[0020] Obtain the database connection pool class through the loading class of the database connection pool;
[0021] Based on the database connection pool class, the SQL information is obtained during the database connection pool interception period, and the SQL information includes the database connection pool metric data.
[0022] In one possible implementation, obtaining the SQL information within the database connection pool's interception period, based on the database connection pool, includes:
[0023] The database connection pool object of the database connection pool class is loaded via reflection;
[0024] During the database connection pool interception period, the maximum number of connections, minimum number of idle connections, number of active connections, and total number of connections of the database connection pool object are obtained from the database connection pool object. The SQL information includes the maximum number of connections, the minimum number of idle connections, the number of active connections, and the total number of connections.
[0025] In one possible implementation, loading the target startup class based on the target process identifier includes:
[0026] The target virtual machine is determined based on the target process identifier;
[0027] The target virtual machine information is determined using the target virtual machine.
[0028] Based on the target virtual machine information, load the target startup class.
[0029] In one possible implementation, the method further includes:
[0030] Receive a virtual machine list retrieval request sent by the second server;
[0031] Based on the virtual machine list retrieval request, multiple candidate virtual machines are determined;
[0032] For any candidate virtual machine, obtain the process identifier corresponding to the candidate virtual machine;
[0033] Based on the process identifier, determine whether the candidate virtual machine is allowed to bind;
[0034] If so, add the candidate virtual machine and the process identifier corresponding to the candidate virtual machine to the virtual machine list;
[0035] The list of virtual machines is sent to the second server.
[0036] Secondly, this application provides an apparatus for determining SQL information, comprising:
[0037] A receiving module is used to receive a binding request message sent by a second server, wherein the binding request message includes a target process identifier;
[0038] The processing module is used to load the target startup class based on the target process identifier;
[0039] The processing module is also used to determine the Structured Query Language (SQL) information based on the target startup class;
[0040] The sending module is used to send the SQL information to the second server.
[0041] In one possible implementation, the processing module is specifically used for:
[0042] Receive indication information sent by the second server, the indication information being used to indicate whether to obtain SQL execution indicator data or database connection pool indicator data;
[0043] Based on the indicated information, the SQL information is determined through the target startup class.
[0044] In one possible implementation, the indication information is used to indicate the acquisition of SQL execution indicator data, and the indication information includes SQL interception parameters, which include the target SQL and the SQL interception period.
[0045] The processing module is specifically used for:
[0046] The enhanced interface is loaded through the target startup class;
[0047] The enhanced interface is used to intercept the target SQL during the SQL interception period to obtain the SQL information, which includes the input parameters, output parameters, and execution time of the target SQL.
[0048] In one possible implementation, the indication information is used to indicate the acquisition of database connection pool indicator data, and the indication information includes the database connection pool interception period;
[0049] The processing module is specifically used for:
[0050] The loading class of the database connection pool is obtained through the target startup class;
[0051] Obtain the database connection pool class through the loading class of the database connection pool;
[0052] Based on the database connection pool class, the SQL information is obtained during the database connection pool interception period, and the SQL information includes the database connection pool metric data.
[0053] In one possible implementation, the processing module is specifically used for:
[0054] The database connection pool object of the database connection pool class is loaded via reflection;
[0055] During the database connection pool interception period, the maximum number of connections, minimum number of idle connections, number of active connections, and total number of connections of the database connection pool object are obtained from the database connection pool object. The SQL information includes the maximum number of connections, the minimum number of idle connections, the number of active connections, and the total number of connections.
[0056] In one possible implementation, the processing module is specifically used for:
[0057] The target virtual machine is determined based on the target process identifier;
[0058] The target virtual machine information is determined using the target virtual machine.
[0059] Based on the target virtual machine information, load the target startup class.
[0060] In one possible implementation, the receiving module is further configured to receive a virtual machine list retrieval request sent by the second server;
[0061] The processing module is further configured to: determine multiple candidate virtual machines based on the virtual machine list acquisition request; for any candidate virtual machine, obtain the process identifier corresponding to the candidate virtual machine; determine whether the candidate virtual machine is allowed to be bound based on the process identifier; if so, add the candidate virtual machine and the process identifier corresponding to the candidate virtual machine to the virtual machine list;
[0062] The sending module is also used to send the list of virtual machines to the second server.
[0063] Thirdly, this application provides an electronic device, including: a processor, and a memory communicatively connected to the processor;
[0064] The memory stores computer-executed instructions;
[0065] The processor executes computer execution instructions stored in the memory to implement the method as described in the first aspect.
[0066] Fourthly, this application provides a computer-readable storage medium storing computer-executable instructions, which, when executed by a processor, are used to implement the method described in the first aspect.
[0067] Fifthly, this application provides a computer program product, including a computer program that, when executed by a processor, implements the method described in the first aspect.
[0068] This application provides a method, apparatus, device, and storage medium for determining SQL information. In this method, a first server receives a binding request message from a second server, the binding request message including a target process identifier; based on the target process identifier, a target startup class is loaded; SQL information is determined using the target startup class; and the SQL information is sent to the second server. The technical solution of this application can non-intrusively obtain the SQL execution status of the database and the status of the database connection pool. Attached Figure Description
[0069] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application.
[0070] Figure 1 This is a schematic diagram of an application scenario provided by an embodiment of this application;
[0071] Figure 2 A flowchart illustrating a method for determining SQL information provided in an embodiment of this application;
[0072] Figure 3A schematic diagram illustrating a process for sending a binding request message, provided as an embodiment of this application;
[0073] Figure 4 A flowchart illustrating another method for determining SQL information provided in an embodiment of this application;
[0074] Figure 5 A flowchart illustrating another method for determining SQL information provided in an embodiment of this application;
[0075] Figure 6 This is a flowchart illustrating a method for obtaining a list of virtual machines provided in an embodiment of this application.
[0076] Figure 7 This is a schematic diagram of the structure of a device for determining SQL information provided in an embodiment of this application;
[0077] Figure 8 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application.
[0078] The accompanying drawings illustrate specific embodiments of this application, which will be described in more detail below. These drawings and descriptions are not intended to limit the scope of the concept in any way, but rather to illustrate the concept of this application to those skilled in the art through reference to particular embodiments. Detailed Implementation
[0079] To make the objectives, technical solutions, and advantages of this application clearer, the technical solutions in the embodiments of this application will be clearly and completely described below in conjunction with the embodiments of this application. Obviously, the described embodiments are only some embodiments of this application, not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0080] It should be noted that although the terms "first," "second," etc., are used to describe various types of information in the embodiments of this application, this information should not be limited to these terms. These terms are only used to distinguish information of the same type from each other. Optionally, without departing from the scope of this application, first information may also be referred to as second information, and similarly, second information may also be referred to as first information.
[0081] It should be understood that the terms "comprising" or "including" indicate the presence of the stated features, steps, or operations, but do not preclude the presence, occurrence, or addition of one or more other features, steps, or operations.
[0082] To facilitate understanding, the following will be combined with... Figure 1 The application scenarios applicable to the embodiments of this application will be described.
[0083] Figure 1 This is a schematic diagram illustrating an application scenario provided by an embodiment of this application. Please refer to [link / reference]. Figure 1 It includes multiple first servers and second servers. Business applications can be set up on the first servers. The second servers can send instruction information to any of the first servers to instruct the first servers to obtain the SQL execution status and database connection pool status of their corresponding databases. After obtaining the SQL execution status and database connection pool status, the first servers send the SQL execution status and database connection pool status to the second servers.
[0084] It should be noted that, Figure 1 This is merely a schematic diagram of one application scenario and does not constitute a limitation on the applicable scenarios of the technical solutions provided in this application.
[0085] To address the technical problems in the prior art, this application provides a method, apparatus, device, and storage medium for determining SQL information. In this method, a second server can determine the SQL execution status of the database and the state of the database connection pool non-intrusively through a target startup class.
[0086] The technical solutions shown in this application will now be described in detail through specific embodiments. It should be noted that the following embodiments may exist independently or in combination with each other, and the same or similar concepts or processes may not be described again in some embodiments.
[0087] Figure 2 This is a flowchart illustrating a method for determining SQL information provided in an embodiment of this application. Please refer to [link / reference]. Figure 2 The methods may include:
[0088] S201. The second server sends a binding request message to the first server. The binding request message includes the target process identifier.
[0089] In other words, the first server receives the binding request message sent by the second server.
[0090] The first server can be the business application server.
[0091] The second server can be a server used to build a diagnostic analysis platform.
[0092] The first server can be configured with multiple virtual machines, which can be Java Virtual Machines (JVMs).
[0093] Each virtual machine can run one Java application.
[0094] The target process identifier can refer to the identifier of the Java application running in the target virtual machine.
[0095] In one possible implementation, the second server can first determine the Java application that needs to be attached, and then send a binding request message to the first server.
[0096] For example, Figure 3 This is a schematic diagram illustrating a process for sending a binding request message, provided as an embodiment of this application. Please refer to... Figure 3 The first server contains three JVMs, each running a Java application. After determining the target Java application to be bound, the second server can send a binding request message to the target JVM in the first server. The binding request message includes the process identifier corresponding to the target Java application.
[0097] S202. The first server loads the target startup class based on the target process identifier.
[0098] In one possible implementation, the target virtual machine in the first server loads the target startup class based on the target process identifier.
[0099] The target startup class can refer to the AgentBootstrap class.
[0100] In one possible implementation, the target startup class can be loaded based on the target process identifier in the following way:
[0101] Based on the target process identifier, determine the target virtual machine; based on the target virtual machine, determine the target virtual machine information; based on the target virtual machine information, load the target startup class.
[0102] For example, based on the target process identifier, the container class (VirtualMachineDescriptor) describing the target virtual machine corresponding to the target process identifier is determined, and the attach method is called to obtain the corresponding target virtual machine information (JVM information). Then, the agent loading (loadAgent) method of the target virtual machine is called to load AgentBootstrap.
[0103] The purpose of this step may be to attach the target Java application.
[0104] S203. The first server determines the SQL information through the target startup class.
[0105] In one possible implementation, the target virtual machine in the first server could determine the SQL information through the target startup class.
[0106] In one possible implementation, the SQL information may include SQL execution metrics or database connection pool metrics.
[0107] The SQL execution metrics data can include the SQL input parameters, SQL output parameters, and SQL execution time.
[0108] Database connection pool metrics can include the maximum number of connections, the minimum number of idle connections, the number of active connections, and the total number of connections.
[0109] The maximum number of connections in the database connection pool can refer to the maximum number of database connections in the connection pool.
[0110] S204. The first server sends SQL information to the second server.
[0111] In other words, the second server receives the SQL information sent by the first server.
[0112] After receiving the SQL information, the second server can visualize the SQL information and analyze the business based on the SQL information to improve the efficiency and convenience of business system problem diagnosis and analysis, and ensure business continuity and stability.
[0113] exist Figure 2 In the illustrated embodiment, the second server sends a binding request message to the first server, the binding request message including a target process identifier; the first server loads a target startup class based on the target process identifier; determines the SQL information through the target startup class; and sends the SQL information to the second server. The technical solution of this application can obtain SQL information non-intrusively.
[0114] exist Figure 2 Based on the illustrated embodiment, the following details how the target virtual machine in the first server determines the SQL information through the target startup class.
[0115] Figure 4 This is a flowchart illustrating another method for determining SQL information provided in an embodiment of this application. Please refer to... Figure 4 The methods may include:
[0116] S401, The second server sends an instruction message to the first server.
[0117] In other words, the first server receives the instruction information sent by the second server.
[0118] In one possible implementation, the second server may send instruction information to the target virtual machine in the first server.
[0119] The instruction information can be used to instruct the retrieval of SQL execution metric data.
[0120] In one possible implementation, the indication information may include SQL interception parameters, which include the target SQL and the SQL interception period. The target SQL may refer to a target SQL field.
[0121] In one possible implementation, the SQL interception parameters may also include SQL regular expression matching.
[0122] In one possible implementation, the second server can determine the SQL interception parameters before sending the instruction information to the first server.
[0123] S402. The first server loads the enhanced interface through the target startup class.
[0124] In one possible implementation, the target virtual machine in the first server can load the enhanced interface through the target startup class.
[0125] Enhanced interfaces can refer to enhanced versions of the java.sql.Connection and java.sql.Statement classes.
[0126] In one possible implementation, ASM can be used to enhance Java's java.sql.Connection and java.sql.Statement classes.
[0127] For example, after the second server receives the instruction information, AgentBootstrap loads the enhanced java.sql.Connection and java.sql.Statement classes. These enhanced classes can intercept SQL queries based on the SQL interception parameters.
[0128] S403. The first server intercepts the target SQL during the SQL interception period through the enhanced interface and obtains the SQL information.
[0129] In one possible implementation, the target virtual machine in the first server can intercept the target SQL during the SQL interception period through an enhanced interface to obtain the SQL information.
[0130] SQL information includes the input parameters of the target SQL, the output parameters of the target SQL, and the execution time of the target SQL.
[0131] In one possible implementation, the target SQL can be intercepted during the SQL interception period to obtain SQL information:
[0132] During the SQL interception period, when the Java application executes SQL, the enhanced java.sql.Connection and java.sql.Statement classes will first intercept the target SQL and obtain the input parameters and the start time of the target SQL execution. After the target SQL execution is completed, the output parameters and the completion time of the target SQL execution will be obtained. Based on the start time and completion time of the target SQL execution, the execution duration of the target SQL can be determined. Subsequently, the target SQL text, the execution duration of the target SQL, the input parameters and the output parameters of the target SQL are included in the SQL information.
[0133] In one possible implementation, since the execution of a single SQL statement involves multiple calls to the `java.sql.Connection` or `java.sql.Statement` methods, a stack can be used to track the execution of the target SQL statement. This involves incrementing the stack depth by 1 when the target SQL statement enters the execution method and decrementing it by 1 when it exits. Because the execution of the target SQL statement is recursive, the execution of the target SQL statement is considered complete when the stack depth reaches 0. Using a stack depth approach avoids the single target SQL statement being counted multiple times.
[0134] In one possible implementation, after the SQL interception period ends, the SQL information during the SQL interception period can be returned to the second server.
[0135] Figure 5 This is a flowchart illustrating another method for determining SQL information provided in an embodiment of this application. Please refer to... Figure 5 The methods may include:
[0136] S501, The second server sends an instruction message to the first server.
[0137] In one possible implementation, the second server may send instruction information to the target virtual machine in the first server.
[0138] The indication information can be used to indicate the retrieval of database connection pool metric data.
[0139] In one possible implementation, the indication information may include a database connection pool interception period.
[0140] S502. The first server obtains the database connection pool loading class through the target startup class.
[0141] In one possible implementation, the target virtual machine in the first server can obtain the loading class of the database connection pool through the target startup class.
[0142] Loading classes can refer to ClassLoader.
[0143] For example, after receiving the instruction information sent by the second server, AgentBootstrap will obtain the ClassLoader of the connection pool.
[0144] S503. The first server obtains the database connection pool class through the database connection pool loading class.
[0145] In one possible implementation, the target virtual machine in the first server can obtain the database connection pool class through the database connection pool loading class.
[0146] In one possible implementation, the database connection pool class may include the Hikari connection pool class, the Druid connection pool class, the JDBC connection pool class, and the DBCP connection pool class.
[0147] S504. The first server obtains SQL information during the database connection pool interception period based on the database connection pool class.
[0148] In one possible implementation, the target virtual machine in the first server can obtain SQL information during the database connection pool interception period based on the database connection pool class.
[0149] SQL information may include database connection pool metrics.
[0150] In one possible implementation, SQL information can be obtained from the database connection pool during the database connection pool interception period in the following ways:
[0151] The database connection pool object of the database connection pool class is loaded using reflection; during the database connection pool interception period, the maximum number of connections, minimum number of idle connections, number of active connections, and total number of connections of the database connection pool object are obtained from the database connection pool object. The SQL information includes the maximum number of connections, minimum number of idle connections, number of active connections, and total number of connections.
[0152] In one possible implementation, after the database connection pool interception period ends, the SQL information (maximum number of connections, minimum number of idle connections, number of active connections, and total number of connections of the database connection pool object) during the database connection pool interception period can be returned to the second server.
[0153] In this embodiment, "non-intrusive" can mean that no configuration or changes are made to the target business code. Dynamically obtaining SQL and database connection pool status can mean obtaining SQL or real-time database connection pool status based on adjustable filtering conditions within a certain period or at a specific point in time.
[0154] Based on any of the above embodiments, before sending the binding request information, the second server also needs to obtain a list of virtual machines so that the second server can determine a suitable target virtual machine for binding and obtain the SQL information of the business application running in the target virtual machine.
[0155] Figure 6 This is a schematic flowchart illustrating a method for obtaining a list of virtual machines provided in an embodiment of this application. Please refer to... Figure 6 The method includes:
[0156] S601, The second server sends a virtual machine list retrieval request to the first server.
[0157] In other words, the first server receives the virtual machine list retrieval request sent by the second server.
[0158] In one possible implementation, the second server may first select a target first server from among the multiple first servers connected to it, and then send a virtual machine list retrieval request to the target first server.
[0159] S602. The first server obtains the request based on the list of virtual machines and determines multiple candidate virtual machines.
[0160] The candidate virtual machine can refer to the virtual machine that calls AttachProvider.
[0161] In one possible implementation, all implementation classes of AttachProvider can be obtained through Java's native Service Provider Interface (SPI) mechanism. Here, the implementation class can refer to the virtual machine that calls AttachProvider.
[0162] AttachProvider can refer to an interface used to bind (attach) to the JVM.
[0163] In one possible implementation, multiple candidate virtual machines can be grouped into a candidate virtual machine list (listVirtualMachines).
[0164] S603. For any candidate virtual machine, the first server obtains the process identifier corresponding to the candidate virtual machine.
[0165] S604. The first server determines whether the candidate virtual machine is allowed to be bound based on the process identifier.
[0166] If so, execute S605 and assemble the candidate virtual machine into VirtualMachineDescriptor.
[0167] If not, then determine the next candidate virtual machine in the candidate virtual machine list, until the entire candidate virtual machine list has been traversed.
[0168] S605. The first server adds the candidate virtual machine and the process identifier corresponding to the candidate virtual machine to the virtual machine list.
[0169] S606, The first server sends a list of virtual machines to the second server.
[0170] In other words, the second server receives the list of virtual machines sent by the first server.
[0171] After receiving the list of virtual machines, the second server can select a target virtual machine from the list and bind the Java application in the target virtual machine.
[0172] The technical solution of this application uses native Java Agent technology to connect to the target Java application at runtime by binding to the Attach Application Programming Interface (Attach API). It uses the Instrumentation API and ASM-enhanced Java's java.sql.Connection and java.sql.Statement class files to intercept methods executing SQL, obtaining information such as the executed SQL and execution duration. It also uses reflection to load the connection pool object of the connection pool class to statistically analyze the connection pool status. This allows for non-intrusive and dynamic acquisition of SQL information (including SQL execution metrics or database connection pool metrics) from the runtime of the Java application. It supports real-time acquisition of SQL information while the application is running and does not restart, providing a visual representation to improve the efficiency and convenience of diagnostic analysis for business systems while ensuring business continuity and reproducing problems, and also guaranteeing business stability.
[0173] Figure 7 This is a schematic diagram of a device for determining SQL information provided in an embodiment of this application. Please refer to... Figure 7 The device 10 for determining the SQL information includes a receiving module 11, a processing module 12, and a sending module 13, wherein...
[0174] The receiving module 11 is used to receive a binding request message sent by the second server, the binding request message including the target process identifier;
[0175] Processing module 12 is used to load the target startup class based on the target process identifier;
[0176] Processing module 12 is also used to determine SQL information based on the target startup class;
[0177] The sending module 13 is used to send SQL information to the second server.
[0178] In one possible implementation, the processing module 12 is specifically used for:
[0179] Receive instruction information sent by the second server, which is used to instruct the retrieval of SQL execution indicator data or database connection pool indicator data;
[0180] Based on the instructions, determine the SQL information through the target startup class.
[0181] In one possible implementation, the indication information is used to indicate the acquisition of SQL execution indicator data, and the indication information includes SQL interception parameters, which include the target SQL and the SQL interception period.
[0182] Processing module 12 is specifically used for:
[0183] The enhanced interface is loaded through the target startup class;
[0184] By enhancing the interface, the target SQL can be intercepted during the SQL interception period to obtain SQL information, including the input parameters, output parameters, and execution time of the target SQL.
[0185] In one possible implementation, the indication information is used to indicate the acquisition of database connection pool indicator data, and the indication information includes the database connection pool interception period;
[0186] Processing module 12 is specifically used for:
[0187] Obtain the database connection pool loading class through the target startup class;
[0188] Obtain the database connection pool class by using the database connection pool loading class;
[0189] Based on the database connection pool class, SQL information is obtained during the database connection pool interception period. The SQL information includes database connection pool metric data.
[0190] In one possible implementation, the processing module 12 is specifically used for:
[0191] Load the database connection pool object of the database connection pool class using reflection;
[0192] During the database connection pool interception period, retrieve the maximum number of connections, minimum number of idle connections, number of active connections, and total number of connections from the database connection pool object. The SQL information includes the maximum number of connections, minimum number of idle connections, number of active connections, and total number of connections.
[0193] In one possible implementation, the processing module 12 is specifically used for:
[0194] The target virtual machine is determined based on the target process identifier;
[0195] Determine the target virtual machine information by using the target virtual machine;
[0196] Load the target startup class based on the target virtual machine information.
[0197] In one possible implementation, the receiving module 11 is further configured to receive a virtual machine list retrieval request sent by the second server;
[0198] The processing module 12 is also used to: determine multiple candidate virtual machines based on the virtual machine list acquisition request; for any candidate virtual machine, obtain the process identifier corresponding to the candidate virtual machine; determine whether the candidate virtual machine is allowed to be bound based on the process identifier; if so, add the candidate virtual machine and the process identifier corresponding to the candidate virtual machine to the virtual machine list;
[0199] The sending module 13 is also used to send a list of virtual machines to the second server.
[0200] The SQL information determination device 10 provided in this application embodiment can execute the technical solution shown in the above method embodiment. Its implementation principle and beneficial effects are similar, and will not be described again here.
[0201] Figure 8 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Please refer to... Figure 8 The electronic device 20 may include a transceiver 21, a memory 22, and a processor 23. The transceiver 21 may include a transmitter and / or a receiver. The transmitter may also be referred to as a transmitter, transmitter port, or transmitter interface, etc., and the receiver may also be referred to as a receiver, receiver port, or receiver interface, etc. Exemplarily, the transceiver 21, memory 22, and processor 23 are interconnected via a bus 24.
[0202] Memory 22 is used to store program instructions;
[0203] The processor 23 is used to execute the program instructions stored in the memory, so that the electronic device 20 executes any of the SQL information determination methods shown above.
[0204] The transceiver 21 is used to perform the transmission and reception functions of the electronic device 20.
[0205] Figure 8 The electronic device shown in the embodiments can execute the technical solutions shown in the above method embodiments. Its implementation principle and beneficial effects are similar, and will not be repeated here.
[0206] This application provides a computer-readable storage medium storing computer-executable instructions and a method for determining SQL information used to implement any of the above-mentioned items when the computer-executable instructions are executed by a processor.
[0207] This application provides a computer program product, including a computer program that, when executed by a processor, can implement the method for determining SQL information as described above.
[0208] Other embodiments of this application will readily occur to those skilled in the art upon consideration of the specification and practice of the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of this application that follow the general principles of this application and include common knowledge or customary techniques in the art not disclosed herein. The specification and examples are to be considered exemplary only, and the true scope and spirit of this application are indicated by the following claims.
[0209] It should be understood that this application is not limited to the precise structure described above and shown in the accompanying drawings, and various modifications and changes can be made without departing from its scope. The scope of this application is limited only by the appended claims.
Claims
1. A method of determining SQL information, characterized by, Applied to a first server, the method comprises: Receiving a binding request message sent by a second server, the binding request message comprising a target process identifier; Loading a target startup class according to the target process identifier; Determining structured query language (SQL) information through the target startup class; Sending the SQL information to the second server; The determining of the SQL information according to the target startup class comprises: Receiving indication information sent by the second server, the indication information being used to indicate acquisition of SQL execution index data or acquisition of database connection pool index data; Determining the SQL information through the target startup class according to the indication information; When the indication information is used to indicate acquisition of SQL execution index data, the indication information comprises a SQL interception parameter, and the SQL interception parameter comprises a target SQL and a SQL interception time period; The determining of the SQL information through the target startup class according to the indication information comprises: Loading an enhanced interface through the target startup class; Intercepting the target SQL in the SQL interception time period through the enhanced interface to obtain the SQL information, the SQL information comprising input parameters of the target SQL, output parameters of the target SQL and an execution time length of the target SQL; wherein, when the target SQL is intercepted in the SQL interception time period, a stack depth statistics method is adopted: when the target SQL enters an execution method, the stack depth is increased by 1, when the target SQL exits the execution method, the stack depth is decreased by 1, and when it is detected that the stack depth is 0, it is determined that the target SQL is executed completely; When the indication information is used to indicate acquisition of database connection pool index data, the indication information comprises a database connection pool interception time period; The determining of the SQL information through the target startup class according to the indication information comprises: Obtaining a loading class of the database connection pool through the target startup class; Obtaining a database connection pool class through the loading class of the database connection pool; Reflectively loading a database connection pool object of the database connection pool class; in the database connection pool interception time period, obtaining a maximum connection number, a minimum idle connection number, an active connection number and a total connection number of the database connection pool object in the database connection pool object, the SQL information comprising the maximum connection number, the minimum idle connection number, the active connection number and the total connection number; the SQL information comprises the database connection pool index data.
2. The method of claim 1, wherein, The loading of the target startup class according to the target process identifier comprises: Determining a target virtual machine according to the target process identifier; Determining target virtual machine information through the target virtual machine; Loading the target startup class according to the target virtual machine information.
3. The method of claim 2, wherein, The method further comprises: Receiving a virtual machine list acquisition request sent by the second server; Determining a plurality of candidate virtual machines according to the virtual machine list acquisition request; For any one candidate virtual machine, obtaining a process identifier corresponding to the candidate virtual machine; Determining whether the candidate virtual machine is allowed to be bound according to the process identifier; If yes, the candidate virtual machine and the process identification corresponding to the candidate virtual machine are added to a virtual machine list; The virtual machine list is sent to the second server.
4. An apparatus for determining SQL information, characterized by, Comprise: The receiving module is configured to receive a binding request message sent by the second server, wherein the binding request message comprises a target process identification; The processing module is configured to load a target start class according to the target process identification; The processing module is further configured to determine structured query language (SQL) information through the target start class; The sending module is configured to send the SQL information to the second server; When determining the SQL information through the target start class according to the indication information, the processing module is specifically configured to receive indication information sent by the second server, wherein the indication information is used to indicate that SQL execution index data is acquired or database connection pool index data is acquired; and the SQL information is determined through the target start class according to the indication information; When the indication information is used to indicate that the SQL execution index data is acquired, and the indication information comprises a SQL interception parameter, the SQL interception parameter comprises a target SQL and a SQL interception time period, when the SQL information is determined through the target start class according to the indication information, the processing module is specifically configured to load an enhanced interface through the target start class; the target SQL is intercepted through the enhanced interface in the SQL interception time period to obtain the SQL information, the SQL information comprises input parameters of the target SQL, output parameters of the target SQL and an execution time length of the target SQL; and when the target SQL is intercepted in the SQL interception time period, a stack depth statistical method is adopted: when the target SQL enters an execution method, the stack depth is increased by 1, when the target SQL exits the execution method, the stack depth is decreased by 1, and when it is detected that the stack depth is 0, it is determined that the target SQL is executed completely; When the indication information is used to indicate that the database connection pool index data is acquired, and the indication information comprises a database connection pool interception time period, when the SQL information is determined through the target start class according to the indication information, the processing module is specifically configured to acquire a loading class of the database connection pool through the target start class; acquire a database connection pool class through the loading class of the database connection pool; reflectively load a database connection pool object of the database connection pool class; acquire a maximum connection number, a minimum idle connection number, an active connection number and a total connection number of the database connection pool object in the database connection pool object in the database connection pool interception time period, and the SQL information comprises the maximum connection number, the minimum idle connection number, the active connection number and the total connection number; and the SQL information comprises the database connection pool index data.
5. An electronic device comprising: A processor and a memory connected with the processor in communication; The memory stores computer execution instructions; The processor executes the computer execution instructions stored in the memory to implement the method in any one of claims 1-3.
6. A computer readable storage medium characterized by, The computer readable storage medium stores computer-executable instructions which, when executed by a processor, implement the method of any one of claims 1-3.
7. A computer program product, characterised in that, A computer program which, when executed by a processor, implements the method of any one of claims 1-3.
Citation Information
Patent Citations
Code debugging method and device, electronic equipment and storage medium
CN111930472A
Automatic index generation method and system based on byte codes
CN113254317A
Management monitoring method and system for database connection pool
CN113934588A
Method, device and computer readable storage medium for managing a virtual machine
US20180300167A1