ODBC Specification-Based Command Conversion Method, System, Computer Device, and Medium

The MYSQL protocol package is obtained through the ODBC specification interface and parsed and converted, which solves the problem of external decoded files that need to be modified in advance, and realizes efficient database calls and parsing, improving decoding efficiency.

CN115510136BActive Publication Date: 2025-07-18BEIJING XINGE TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202211172069.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-09-26
Publication Date
2025-07-18
Estimated Expiration
2042-09-26

AI Technical Summary

Technical Problem

In the prior art, when inputting external decoded files through the ODBC specification interface to the server for database calls, the external decoded files need to be modified in advance, resulting in an increase in the burden on staff when there are too many files and affecting work efficiency.

Method used

The MYSQL protocol package input by the user is obtained through the ODBC specification interface, and it is parsed and converted using the protocol server, generates an interface conversion parameter set, and directly calls the database's JDBC specification interface group for execution, realizing calls and parsing without the need for preliminary operations on external decoded files.

Benefits of technology

It realizes that database calls and parsing can be done without pre-modifying external decoded files, improving decoding efficiency and reducing the burden on staff.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115510136B_ABST
    Figure CN115510136B_ABST
Patent Text Reader

Abstract

The present invention discloses a command conversion method, system, computer device and medium based on the ODBC specification. By obtaining the MYSQL protocol packet (i.e., the external decoding file) input by the user through the ODBC specification interface, and making a targeted call and parsing of the MYSQL protocol packet according to the statement type included in the MYSQL protocol packet, it realizes the pre-call and parsing of MYSQL protocol packets of multiple different statement types by setting up a protocol server, and realizes the technical effect that the input call and parsing can be directly carried out through the ODBC specification interface without performing prior operations on the MYSQL protocol packet, solving the problem in the prior art that when the external decoding file needs to be input into the server through the ODBC specification interface for database call and execution in the existing decoding method, it is necessary to modify the external decoding file in advance, resulting in a heavy workload for staff when there are too many external decoding files to be accessed, which is not conducive to improving work efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to command conversion, and in particular to a command conversion method, system, computer device and medium based on the ODBC specification. Background Art

[0002] The ODBC specification (Open Database Connectivity) technology launched by Mcrosoft provides a unified interface for accessing heterogeneous databases. The ODBC specification is based on SQL (Structured Query Language) and uses it as the standard for accessing databases. This ODBC specification interface provides the maximum interoperability. An application can access different database management systems through a set of common codes. At the same time, a client / server application developed by a software developer is not bound to a specific database. Therefore, the ODBC specification can provide corresponding drivers for different databases. However, since there are a large number of ODBC specification interfaces in the SQL database currently, when an external decoding file needs to be input into the server through the ODBC specification interface for database call and execution, the external decoding file needs to be modified in advance. When there are too many external decoding files to be accessed, a large amount of modification work for external decoding files causes a burden on the staff and is not conducive to improving work efficiency. Summary of the Invention

[0003] Based on this, in view of the above problems, it is necessary to propose a command conversion method, system, computer device and medium based on the ODBC specification that can be input into the server through the ODBC specification interface for database call and execution without modifying the external decoding file, thereby improving the call efficiency.

[0004] The present invention discloses a command conversion method based on the ODBC specification, including a protocol server, an ODBC specification interface, a database, and a background system. One end of the protocol server is connected to the ODBC specification interface, and the other end of the protocol server is connected to the database. The background system is also connected to the ODBC specification interface and the database. The method includes:

[0005] The background system determines whether the command type included in the MYSQL protocol packet input by the ODBC specification interface is a query command;

[0006] If so, the protocol server parses the statements included in the MYSQL protocol packet to generate a set of parsed statements;

[0007] The protocol server determines whether the parsed statements included in the set of parsed statements are only MYSQL statements;

[0008] If so, the protocol server converts the MYSQL statement into an interface conversion parameter set and provides it for the JDBC specification interface group in the database to call and execute, thereby converting it into a conversion result set;

[0009] The database sends the conversion result set to the background system.

[0010] Further, the JDBC specification interface group includes a getProdedures interface, and the conversion result set includes a show procedure result set;

[0011] Then the step of the protocol server converting the MYSQL statement into an interface conversion parameter set and providing it for the JDBC specification interface group in the database to call and execute, thereby converting it into a conversion result set specifically includes:

[0012] The protocol server determines whether the command type prefix of the MYSQL statement is of the show type;

[0013] If so, it determines whether the command type of the MYSQL statement is a show procedure command;

[0014] If so, it obtains a first preset regular expression that matches the show procedure command;

[0015] Obtains a first matching parameter in the MYSQL statement and inputs the first matching parameter into the first preset regular expression for calculation, thereby calculating a first interface conversion parameter;

[0016] The database calls the getProdedures interface in the JDBC specification interface to convert the first interface conversion parameter, thereby generating a show procedure result set.

[0017] Further, the JDBC specification interface group includes a getDatabases interface, and the conversion result set includes a show databases result set;

[0018] After the step that the protocol server determines whether the command type prefix of the MYSQL statement is of the show type, it further includes:

[0019] If so, the protocol server determines whether the command type of the MYSQL statement is a show databases command;

[0020] If so, obtain a second preset regular expression that matches the "show databases" command;

[0021] Obtain a second matching parameter within the MYSQL statement, and input the second matching parameter into the second preset regular expression for calculation, thereby inferring a second interface conversion parameter;

[0022] Call the getDatabases interface in the JDBC specification interface to convert the second interface conversion parameter, thereby generating a "show databases" result set.

[0023] Furthermore, it is characterized in that the JDBC specification interface group includes a getIndexs interface, and the conversion result set includes a "show Indexs" result set;

[0024] After the step where the protocol server determines whether the command type prefix of the MYSQL statement is of the "show" type, it further includes:

[0025] If so, determine whether the command type of the interface conversion parameter set is a "show Indexs" command;

[0026] If so, obtain a third preset regular expression that matches the "show Indexs" command;

[0027] Obtain a third matching parameter within the MYSQL statement, and input the third matching parameter into the third preset regular expression for calculation, thereby inferring a third interface conversion parameter;

[0028] Call the getIndexs interface in the JDBC specification interface to convert the third interface conversion parameter, thereby generating a "show Indexs" result set.

[0029] Furthermore, the JDBC specification interface group includes a getTables interface, and the conversion result set includes a "showTables" result set;

[0030] After the step where the protocol server determines whether the command type prefix of the MYSQL statement is of the "show" type, it further includes:

[0031] If so, determine whether the command type of the interface conversion parameter set is a "show Tables" command;

[0032] If so, obtain a fourth preset regular expression that matches the "show Tables" command;

[0033] Obtain the fourth matching parameter within the MYSQL statement, and input the fourth matching parameter into the fourth preset regular expression for calculation, so as to deduce the fourth interface conversion parameter;

[0034] Call the getTables interface in the JDBC specification interface to convert the fourth interface conversion parameter, so as to generate a show Tables result set.

[0035] Further, after the step where the protocol server determines whether the command type prefix of the MYSQL statement is of the show type, the following is also included:

[0036] If not, then determine whether the command type of the MYSQL statement is a Select query command;

[0037] If so, then call the JDBC specification interface group to input the MYSQL statement into the database for execution, so as to output a first execution result set that matches the MYSQL protocol specified format;

[0038] Add the first execution result set to the conversion result set and send it to the background system;

[0039] Among them, after the step of determining whether the command type of the MYSQL statement is a Select query command, the following is also included:

[0040] If not, then call the JDBC specification interface group to input the MYSQL statement into the database for execution, so as to output a second execution result set;

[0041] Add the second execution result set to the conversion result set and send it to the background system.

[0042] Further, after the step where the background system determines whether the command type included in the MYSQL protocol packet input by the ODBC specification interface is a query command, the following is also included:

[0043] If not, then the background system determines again whether the command type included in the MYSQL protocol packet is a ping command;

[0044] If so, after the background system disconnects the connection between the protocol server and the database, the protocol server sends a connection request to the database again;

[0045] Determine whether the database connection is successful. If so, send a ping command success message to the background system, so as to complete the connection test between the protocol server and the database;

[0046] After the step of determining whether the command type included in the input MYSQL protocol packet is a query command, the following steps are further included:

[0047] If not, determine whether the command type included in the MYSQL protocol packet is a database replacement command;

[0048] If so, after updating the database, send a connection request to the updated database;

[0049] Determine whether the database is successfully connected. If so, send a database update success message to the background system.

[0050] The present invention also discloses a command conversion system based on the ODBC specification, including a protocol server, an ODBC specification interface, a database, and a background system. One end of the protocol server is connected to the ODBC specification interface, the other end of the protocol server is connected to the database, the background system is also connected to the ODBC specification interface and the database, and the system includes:

[0051] A command judgment unit for enabling the background system to judge whether the command type included in the MYSQL protocol packet input by the ODBC specification interface is a query command;

[0052] An analysis unit for judging that if so, the protocol server analyzes the statements included in the MYSQL protocol packet to generate an analysis statement set;

[0053] A statement judgment unit for judging whether the analysis statements included in the analysis statement set judged by the protocol server are only MYSQL statements;

[0054] A calling unit for judging that if so, the protocol server converts the MYSQL statements into an interface conversion parameter set for the JDBC specification interface group in the database to call and execute, so as to convert into a conversion result set;

[0055] A sending unit for the database to send the conversion result set to the background system.

[0056] A computer device includes a memory and a processor. When the computer program stored in the memory is executed by the processor, the processor executes the following steps:

[0057] The background system judges whether the command type included in the MYSQL protocol packet input by the ODBC specification interface is a query command;

[0058] If so, the protocol server analyzes the statements included in the MYSQL protocol packet to generate an analysis statement set;

[0059] The protocol server determines whether the parsing statements included in the parsing statement set are only MYSQL statements;

[0060] If so, the protocol server converts the MYSQL statements into an interface conversion parameter set for the JDBC specification interface group in the database to call and execute, so as to be converted into a conversion result set;

[0061] The database sends the conversion result set to the background system.

[0062] A computer-readable medium stores a computer program. When the computer program is executed by a processor, the processor is caused to perform the following steps:

[0063] The background system determines whether the command type included in the MYSQL protocol packet input by the ODBC specification interface is a query command;

[0064] If so, the protocol server parses the statements included in the MYSQL protocol packet to generate a parsing statement set;

[0065] The protocol server determines whether the parsing statements included in the parsing statement set are only MYSQL statements;

[0066] If so, the protocol server converts the MYSQL statements into an interface conversion parameter set for the JDBC specification interface group in the database to call and execute, so as to be converted into a conversion result set;

[0067] The database sends the conversion result set to the background system.

[0068] The above command conversion method, system, computer device and medium based on the ODBC specification obtain the MYSQL protocol packet (i.e., the external decoding file) input by the user through the ODBC specification interface, and perform targeted call parsing on the MYSQL protocol packet according to the statement type included in the MYSQL protocol packet, realizing the pre-call and parsing of MYSQL protocol packets of multiple different statement types by setting a protocol server, achieving the effect of directly inputting, calling and parsing through the ODBC specification interface without performing pre-operations on the MYSQL protocol packet, solving the problem in the prior art that when an external decoding file needs to be input to the server through the ODBC specification interface for database call and execution in the existing decoding method, the external decoding file needs to be modified in advance, resulting in a heavy workload for staff when there are too many external decoding files to be accessed, which is not conducive to improving work efficiency, and improving the decoding efficiency. Description of the Drawings

[0069] In order to more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the following will briefly introduce the accompanying drawings required for use in the description of the embodiments or the prior art. Obviously, the accompanying drawings in the following description are only some embodiments of the present invention. For those of ordinary skill in the art, without creative efforts, other accompanying drawings can also be obtained based on these drawings.

[0070] Among them:

[0071] Figure 1 It is a schematic flowchart of a command conversion method based on the ODBC specification in an embodiment;

[0072] Figure 2 It is a system structure diagram of a command conversion system based on the ODBC specification in an embodiment;

[0073] Figure 3 It is a structural block diagram of a computer device in an embodiment;

[0074] Figure 4 It is a connection schematic diagram among a protocol server, an ODBC specification interface, and a database in an embodiment. Specific embodiments

[0075] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, rather than all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative efforts belong to the scope of protection of the present invention.

[0076] Refer to Figure 1 and Figure 4 , the present invention discloses a command conversion method based on the ODBC specification, including a protocol server 2, an ODBC specification interface 1, a database 3, and a background system 4. One end of the protocol server 2 is connected to the ODBC specification interface 1, the other end of the protocol server 2 is connected to the database 3, and the background system 4 is also connected to the ODBC specification interface 1 and the database 3. The method includes:

[0077] S1. The background system determines whether the command type included in the MYSQL protocol packet input by the ODBC specification interface is a query command;

[0078] As in step S1 above, the background system obtains the external decoding file input through the ODBC standard interface. After that, the background system decodes the external decoding file using the ODBC standard driver that matches the ODBC standard interface, so as to obtain the MYSQL protocol packet contained in the external decoding file. Then, the background system determines whether the command type contained in the MYSQL protocol packet is a query command.

[0079] In addition, the background system is generally a background server. In addition, the background system can be an independent server or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, Content Delivery Network (CDN), and big data and artificial intelligence platforms. The present invention does not make any limitations in this regard.

[0080] S2. If so, the protocol server parses the statements contained in the MYSQL protocol packet to generate a set of parsed statements.

[0081] As in step S2 above, when the background system determines that the command type contained in the MYSQL protocol packet is a query command, the background system parses the statements contained in the MYSQL protocol packet through the protocol server, thereby outputting a number of parsed statements, achieving the function of parsing all external decoding files with the command type of query command. Then, the background system integrates all the parsed statements into a set of parsed statements.

[0082] S3. The protocol server determines whether the parsed statements contained in the set of parsed statements are MYSQL statements.

[0083] As in step S3 above, after the protocol server parses the statements contained in the MYSQL protocol packet into a set of parsed statements, it determines whether the parsed statements contain no other format command statements except MYSQL statements, so as to prevent other format command statements generated during the parsing of the MYSQL protocol packet from entering the subsequent steps and causing parsing errors, and achieving the function of specifically processing MYSQL statements.

[0084] S4. If so, the protocol server converts the MYSQL statements into a set of interface conversion parameters for the JDBC standard interface group in the database to call and execute, thereby converting them into a set of conversion results.

[0085] As in step S4 above, after the protocol server finishes judging whether the parsing statement is a MYSQL statement, the protocol server converts the MYSQL statement so that the MYSQL statement is converted into an interface conversion parameter set in the protocol server and then sent to the database for invocation and execution by the JDBC specification interface group, thereby outputting the conversion result set after being executed by the database.

[0086] S5. The database sends the conversion result set to the background system.

[0087] As described in step S5 above, after the database outputs the conversion result via the JDBC specification interface group, it sends the conversion result set to the background system, thereby completing the conversion of the external decoding file.

[0088] It can be understood that through the above steps, the background system can directly perform multi-level screening on the obtained external decoding file, so that the external decoding file that meets the screening conditions is called and converted by the database and then the conversion result set is sent to the background system, and the external decoding file that does not meet the screening conditions is automatically subjected to other processing, thereby realizing the function of directly inputting the database for invocation and execution without prior processing of the external decoding file, and then outputting the conversion result.

[0089] In this embodiment, through the above method, the MYSQL protocol packet (i.e., the external decoding file) input by the user is obtained through the ODBC specification interface, and the MYSQL protocol packet is specifically called and parsed according to the statement type included in the MYSQL protocol packet, realizing the call and parsing operations for MYSQL protocol packets of various different statement types, and realizing the technical effect of directly inputting, calling and parsing through the ODBC specification interface without prior operation on the MYSQL protocol packet, solving the problem in the prior art that when the external decoding file needs to be input into the server through the ODBC specification interface for database call and execution in the existing decoding method, the external decoding file needs to be modified in advance, resulting in a heavy workload for the staff when there are too many external decoding files to be accessed, which is not conducive to improving work efficiency, and improving the decoding efficiency of the decoding file.

[0090] In one embodiment, the JDBC specification interface group includes a getProdedures interface, and the conversion result set includes a show procedure result set;

[0091] Then step S4 specifically includes:

[0092] S41. The protocol server determines whether the command type prefix of the MYSQL statement is of the show type. If so, it determines whether the command type of the MYSQL statement is the show procedure command. If so, it obtains the first preset regular expression that matches the show procedure command, obtains the first matching parameter within the MYSQL statement, and inputs the first matching parameter into the first preset regular expression for calculation, thereby inferring the first interface conversion parameter. The database calls the getProdedures interface in the JDBC specification interface to convert the first interface conversion parameter, thereby generating a show procedure result set.

[0093] As described in the above steps, after the protocol server obtains the MYSQL statement, it parses the MYSQL statement and determines whether the prefix of the command type of the MYSQL statement is of the show type. If the protocol server determines that the prefixes of the command types of the MYSQL statements are all of the show type, the protocol server filters the MYSQL statements again. Specifically,

[0094] The protocol server first obtains the first preset regular expression that matches the show procedure command. It can be understood that the first preset regular expression is pre-stored in the protocol server by the user. After that, the protocol server obtains the matching parameter within the show procedure command and records it as the first matching parameter. Then, it inputs the first matching parameter into the first preset regular expression for calculation, thereby inferring the first interface conversion parameter. After that, the database calls the getProdedures interface in the JDBC specification interface set inside the database to call and infer the first interface conversion parameter, thereby generating a show procedure result set inferred by the database, that is, completing the function of converting an external decoding file with the command type of show procedure input through the protocol server and the database into a conversion result set.

[0095] In an embodiment, the JDBC specification interface group includes the getDatabases interface, and the conversion result set includes the show databases result set;

[0096] After the step where the protocol server determines whether the command type prefix of the MYSQL statement is of the show type, it further includes:

[0097] S42. If so, the protocol server determines whether the command type of the MYSQL statement is a show databases command. If so, it obtains a second preset regular expression that matches the show databases command, obtains a second matching parameter within the MYSQL statement, and inputs the second matching parameter into the second preset regular expression for calculation, thereby inferring a second interface conversion parameter. It then calls the getDatabases interface in the JDBC specification interface to convert the second interface conversion parameter, thereby generating a show databases result set.

[0098] As described in the above steps, after the protocol server determines that the prefix of the command type of the MYSQL statement is of the show type, the protocol server filters the MYSQL statement again, specifically as follows:

[0099] The protocol server first obtains a second preset regular expression that matches the show databases command. It can be understood that the second preset regular expression is pre-stored in the protocol server by the user. Then, the protocol server obtains the matching parameter within the show databases command, records it as the second matching parameter, and inputs the second matching parameter into the second preset regular expression for calculation, thereby inferring a second interface conversion parameter. Then, the database calls the getDatabases interface in the JDBC specification interface set inside the database to call and infer the second interface conversion parameter, thereby generating a show databases result set inferred by the database, that is, completing the function of converting an externally decoded file with a command type of show databases input through the protocol server and the database into a conversion result set.

[0100] In one embodiment, the JDBC specification interface group includes a getIndexs interface, and the conversion result set includes a showIndexs result set;

[0101] After the step where the protocol server determines whether the prefix of the command type of the MYSQL statement is of the show type, it further includes:

[0102] S43. If so, determine whether the command type of the interface conversion parameter set is the show Indexs command. If so, obtain the third preset regular expression that matches the show Indexs command, obtain the third matching parameter in the MYSQL statement, and input the third matching parameter into the third preset regular expression for calculation, so as to deduce the third interface conversion parameter. Then, call the getIndexs interface in the JDBC specification interface to convert the third interface conversion parameter, thereby generating a show Indexs result set.

[0103] As described in the above steps, after the protocol server determines that the prefix of the command type of the MYSQL statement is of the show type, the protocol server filters the MYSQL statement again, which is specifically manifested as follows:

[0104] The protocol server first obtains the third preset regular expression that matches the show Indexs command. It can be understood that the third preset regular expression is pre-stored in the protocol server by the user. Then, after the protocol server obtains the matching parameter in the showIndexs command and records it as the third matching parameter, it inputs the third matching parameter into the third preset regular expression for calculation, so as to deduce the third interface conversion parameter. Then, the database calls the getIndexs interface in the JDBC specification interface set inside the database to call and deduce the third interface conversion parameter, thereby generating a show Indexs result set deduced by the database, that is, the function of converting an external decoding file with the command type of show Indexs input through the protocol server and the database into a conversion result set is completed.

[0105] In one embodiment, the JDBC specification interface group includes a getTables interface, and the conversion result set includes a showTables result set;

[0106] After the step in which the protocol server determines whether the prefix of the command type of the MYSQL statement is of the show type, the following steps are further included:

[0107] S44. If so, determine whether the command type of the interface conversion parameter set is the show Tables command. If so, obtain the fourth preset regular expression that matches the show Tables command, obtain the fourth matching parameter in the MYSQL statement, and input the fourth matching parameter into the fourth preset regular expression for calculation, so as to deduce the fourth interface conversion parameter. Then, call the getTables interface in the JDBC specification interface to convert the fourth interface conversion parameter, thereby generating a show Tables result set.

[0108] As described in the above steps, if the protocol server determines that the prefixes of the command types of the MYSQL statements are all of the show type, the protocol server filters the MYSQL statements again, specifically as follows:

[0109] The protocol server first obtains the fourth preset regular expression that matches the show Tables command. It can be understood that the fourth preset regular expression is pre-stored by the user in the protocol server. After that, the protocol server obtains the matching parameters in the show Tables command and records them as the fourth matching parameters, and then inputs the fourth matching parameters into the fourth preset regular expression for calculation, so as to deduce the fourth interface conversion parameter. Then the database calls the getTables interface in the JDBC specification interface set internally set in the database to call and deduce the fourth interface conversion parameter, so as to generate the show Tables result set deduced by the database, that is, the function of converting the external decoding file with the command type of show Tables input through the protocol server and the database into the conversion result set is completed.

[0110] In one embodiment, after the step in which the protocol server determines whether the prefix of the command type of the MYSQL statement is of the show type, the following is further included:

[0111] S45. If not, then determine whether the command type of the MYSQL statement is a Select query command. If so, call the JDBC specification interface group to input the MYSQL statement into the database for execution, so as to output the first execution result set that matches the format specified by the MYSQL protocol, add the first execution result set to the conversion result set and send it to the background system.

[0112] As described in the above steps, if the protocol server determines that the prefix of the command type of the MYSQL statement is not of the show type, the protocol server 2 determines again whether the command type of the MYSQL statement is a Select query command. If so, at this time, the database 3 calls the internally set JDBC specification interface, so as to input the MYSQL statement into the database 3 for execution, so that the database 3 outputs the first execution result set that matches the preset MYSQL protocol specified format. After that, the database 3 adds the first execution result set to the conversion result set and sends it to the background system 4, so as to complete the function of converting the external decoding file with the command type of Select of the input MYSQL statement into the conversion result set through the protocol server 2 and the database 3.

[0113] Among them, after the step of determining whether the command type of the MYSQL statement is a Select query command, the following is further included:

[0114] S45. If not, then call the JDBC specification interface group to input the MYSQL statement into the database for execution, so as to output a second execution result set, add the second execution result set to the conversion result set and send it to the background system.

[0115] As described in the above steps, if the protocol server determines that the prefix of the command type of the MYSQL statement is not of the show type and the command type of the MYSQL statement is not a Select query command, then at this time the database calls the internally set JDBC specification interface, so as to input the MYSQL statement into the database for execution, so that the database outputs a second execution result set. After that, the database adds the second execution result set to the conversion result set and sends it to the background system, thus completing the function of converting the external decoding file with the command type of the input MYSQL statement not being Select and the prefix of the command type not being of the show type into a conversion result set through the protocol server 2 and the database 3.

[0116] In one embodiment, after the step S1, it further includes:

[0117] S11. If not, then the background system determines again whether the command type included in the MYSQL protocol packet is a ping command. If so, after the background system cuts off the connection between the protocol server and the database, the protocol server sends a connection request to the database again, determines whether the database is successfully connected. If so, it sends a ping command success message to the background system, thus completing the connection test between the protocol server and the database.

[0118] As described in the above steps, if the protocol server determines that the prefix of the command type of the MYSQL statement is not of the show type, then the protocol server determines again whether the command type of the MYSQL statement is a ping command. If so, the background system 4 controls the protocol server 2 and the database 3 to perform a connection test, specifically manifested as:

[0119] After the background system 4 cuts off the connection between the protocol server 2 and the database 3, the protocol server 2 sends a connection request to the database 3 again, so that the database 3 and the protocol server 2 are reconnected. After that, the protocol server determines whether it is successfully connected to the database. If so, it sends a ping command success message to the background system, thus completing the function of performing a connection test between the protocol server and the database according to the ping command in the external decoding file.

[0120] Among them, after the step S1, it further includes:

[0121] S12. If not, determine whether the command type included in the MYSQL protocol packet is a database replacement command. If so, after updating the database, send a connection request to the updated database, and determine whether the database connection is successful. If so, send a database update success message to the background system.

[0122] As described in the above steps, if the protocol server determines that the prefix of the command type of the MYSQL statement is not of the show type, the protocol server then determines again whether the command type of the MYSQL statement is a database replacement command. If so, at this time, the background system 4 controls the database 3 to be automatically updated, and after the database 3 is updated, the protocol server 2 sends a connection request to the database 3 again, so that a reconnection is made between the updated database 3 and the protocol server 2. After that, the protocol server 2 determines whether it is successfully connected to the updated database 3. If so, a database 3 update success message is sent to the background system 4, thus completing the function of reconnecting after the database 3 is updated according to the database update command in the external decoding file.

[0123] Reference Figure 2 , the present invention also discloses a command conversion system based on the ODBC specification, which is characterized by including a protocol server 2, an ODBC specification interface 1, a database 3, and a background system 4. One end of the protocol server 2 is connected to the ODBC specification interface 1, the other end of the protocol server 2 is connected to the database 3, and the background system 4 is also connected to the ODBC specification interface 1 and the database 3. The system includes:

[0124] A command judgment unit 10, configured to enable the background system to determine whether the command type included in the MYSQL protocol packet input by the ODBC specification interface is a query command;

[0125] An analysis unit 20, configured to determine that if so, the protocol server analyzes the statements included in the MYSQL protocol packet to generate an analysis statement set;

[0126] A statement judgment unit 30, configured to determine whether the analysis statements included in the analysis statement set determined by the protocol server are MYSQL statements;

[0127] An invocation unit 40, configured to determine that if so, the protocol server converts the MYSQL statement into an interface conversion parameter set for invocation and execution by the JDBC specification interface group in the database, so as to be converted into a conversion result set;

[0128] A sending unit 50, configured to send the conversion result set by the database to the background system.

[0129] The above-mentioned units are for implementing the above-mentioned command conversion system based on the ODBC specification, which will not be introduced one by one here.

[0130] Figure 3 The internal structure diagram of a computer device in an embodiment is shown. The computer device may specifically be a server, and the server includes but is not limited to high-performance computers and high-performance computer clusters. As Figure 3 shown, the computer device includes a processor, a memory, and a network interface connected through a system bus. Among them, the memory includes a non-volatile storage medium and an internal memory. The non-volatile storage medium of the computer device stores an operating system and may also store a computer program. When the computer program is executed by the processor, the processor can implement the employee status judgment method. The internal memory may also store a computer program. When the computer program is executed by the processor, the processor can execute the command conversion method based on the ODBC specification.

[0131] In one embodiment, the customer behavior recognition method provided by the present invention can be implemented in the form of a computer program, and the computer program can run on a computer device as Figure 3 shown. Each program template constituting the mail automatic classification and aggregation device can be stored in the memory of the computer device. For example: the command judgment unit 10, the parsing unit 20, the statement judgment unit 30, the calling unit 40, and the sending unit 50.

[0132] A computer device includes a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the following steps are implemented:

[0133] The background system judges whether the command type included in the MYSQL protocol packet input through the ODBC specification interface is a query command. If so, the protocol server parses the statements included in the MYSQL protocol packet to generate a parsed statement set. The protocol server judges whether the parsed statements included in the parsed statement set are MYSQL statements. If so, the protocol server converts the MYSQL statements into an interface conversion parameter set for the JDBC specification interface group in the database to call and execute, so as to convert them into a conversion result set, and the database sends the conversion result set to the background system.

[0134] As can be seen from the above embodiments, the greatest beneficial effect of the present invention is that the MYSQL protocol packet (i.e., the external decoding file) input by the user is obtained through the ODBC standard interface, and the MYSQL protocol packet is specifically called and parsed according to the statement type included in the MYSQL protocol packet. It realizes the early call and parsing of MYSQL protocol packets of various different statement types by setting up a protocol server, and realizes the effect of directly inputting, calling and parsing through the ODBC standard interface without performing prior operations on the MYSQL protocol packet. It solves the problem in the prior art that in the existing decoding method, when the external decoding file needs to be input into the server through the ODBC standard interface for database call and execution, the external decoding file needs to be modified in advance. When there are too many external decoding files to be accessed, a large amount of modification work on the external decoding files causes a heavy burden on the staff and is not conducive to improving work efficiency, and improves the decoding efficiency.

[0135] Those of ordinary skill in the art can understand that all or part of the processes of implementing the methods in the above embodiments can be completed by instructing relevant hardware through a computer program. The program can be stored in a non-volatile computer-readable storage medium. When the program is executed, it can include the processes of the embodiments of the above methods. Among them, any reference to a memory, storage, database or other medium used in the various embodiments provided by the present invention can include non-volatile and / or volatile memories. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), and double data rate, etc.

[0136] The technical features of the above embodiments can be combined arbitrarily. For the sake of concise description, not all possible combinations of the technical features in the above embodiments are described. However, as long as these combinations of technical features do not conflict, they should be considered as the scope described in this specification.

[0137] The above embodiments only represent several implementation manners of the present invention. The description is relatively specific and detailed, but it cannot be understood as a limitation on the scope of the patent of the present invention. It should be noted that for those of ordinary skill in the art, without departing from the concept of the present invention, several deformations and improvements can still be made, and these all belong to the protection scope of the present invention. Therefore, the protection scope of the patent of the present invention should be subject to the appended claims.

Claims

1. A command conversion method based on the ODBC specification, characterized in that, It includes a protocol server, an ODBC specification interface, a database, and a background system. One end of the protocol server is connected to the ODBC specification interface, and the other end of the protocol server is connected to the database. The background system is also connected to the ODBC specification interface and the database. The method includes: The background system determines whether the command type included in the MYSQL protocol packet input by the ODBC specification interface is a query command; If so, the protocol server parses the statements included in the MYSQL protocol packet to generate a set of parsed statements; The protocol server determines whether the parsed statements included in the set of parsed statements are only MYSQL statements; If so, the protocol server converts the MYSQL statements into a set of interface conversion parameters for the JDBC specification interface group in the database to call and execute, thereby converting them into a set of conversion results; The database sends the set of conversion results to the background system.

2. The command conversion method based on the ODBC specification according to claim 1, wherein The JDBC specification interface group includes a getProdedures interface, and the set of conversion results includes a show procedure result set; Then the step of the protocol server converting the MYSQL statements into a set of interface conversion parameters for the JDBC specification interface group in the database to call and execute, thereby converting them into a set of conversion results specifically includes: The protocol server determines whether the command type prefix of the MYSQL statement is of the show type; If so, it determines whether the command type of the MYSQL statement is a show procedure command; If so, it obtains a first preset regular expression that matches the show procedure command; Obtains a first matching parameter in the MYSQL statement and inputs the first matching parameter into the first preset regular expression for calculation, thereby calculating a first interface conversion parameter; The database calls the getProdedures interface in the JDBC specification interface to convert the first interface conversion parameter, thereby generating a show procedure result set.

3. The command conversion method based on the ODBC specification according to claim 2, wherein The JDBC specification interface group includes a getDatabases interface, and the set of conversion results includes a show databases result set; After the step where the protocol server determines whether the command type prefix of the MYSQL statement is of the show type, it further includes: If so, the protocol server determines whether the command type of the MYSQL statement is a show databases command; If so, it obtains a second preset regular expression that matches the show databases command; Obtains a second matching parameter in the MYSQL statement and inputs the second matching parameter into the second preset regular expression for calculation, thereby calculating a second interface conversion parameter; Invoke the getDatabases interface in the JDBC specification interface to convert the second interface conversion parameter, thereby generating a show databases result set.

4. The command conversion method based on the ODBC specification according to claim 2, wherein, The JDBC specification interface group includes a getIndexs interface, and the conversion result set includes a showIndexs result set; After the step where the protocol server determines whether the command type prefix of the MYSQL statement is of the show type, it further includes: If so, determine whether the command type of the interface conversion parameter set is a show Indexs command; If so, obtain a third preset regular expression that matches the show Indexs command; Obtain a third matching parameter within the MYSQL statement, and input the third matching parameter into the third preset regular expression for calculation, thereby inferring a third interface conversion parameter; Invoke the getIndexs interface in the JDBC specification interface to convert the third interface conversion parameter, thereby generating a show Indexs result set.

5. The command conversion method based on the ODBC specification according to claim 2, wherein The JDBC specification interface group includes a getTables interface, and the conversion result set includes a show Tables result set; After the step where the protocol server determines whether the command type prefix of the MYSQL statement is of the show type, it further includes: If so, determine whether the command type of the interface conversion parameter set is a show Tables command; If so, obtain a fourth preset regular expression that matches the show Tables command; Obtain a fourth matching parameter within the MYSQL statement, and input the fourth matching parameter into the fourth preset regular expression for calculation, thereby inferring a fourth interface conversion parameter; Invoke the getTables interface in the JDBC specification interface to convert the fourth interface conversion parameter, thereby generating a show Tables result set.

6. The command conversion method based on the ODBC specification according to claim 2, characterized in that After the step where the protocol server determines whether the command type prefix of the MYSQL statement is of the show type, it further includes: If not, determine whether the command type of the MYSQL statement is a Select query command; If so, invoke the JDBC specification interface group to input the MYSQL statement into the database for execution, thereby outputting a first execution result set that matches the MYSQL protocol specified format; Add the first execution result set to the conversion result set and send it to the background system; Among them, after the step of determining whether the command type of the MYSQL statement is a Select query command, it further includes: If not, then invoke the JDBC specification interface group to input the MYSQL statement into the database for execution, thereby outputting a second execution result set; Add the second execution result set to the conversion result set and send it to the background system.

7. The command conversion method based on the ODBC specification according to claim 1, characterized in that, After the step where the background system determines whether the command type included in the MYSQL protocol packet input by the ODBC specification interface is a query command, it further includes: If not, the background system determines again whether the command type included in the MYSQL protocol packet is a ping command; If so, after the background system disconnects the protocol server from the database, the protocol server sends a connection request to the database again; Determine whether the database connection is successful. If so, send a ping command success message to the background system, thereby completing the connection test between the protocol server and the database; Among them, after the step of determining whether the command type included in the input MYSQL protocol packet is a query command, it further includes: If not, determine whether the command type included in the MYSQL protocol packet is a database replacement command; If so, after updating the database, send a connection request to the updated database; Determine whether the database connection is successful. If so, send a database update success message to the background system.

8. A command conversion system based on the ODBC specification, characterized in that, It includes a protocol server, an ODBC specification interface, a database, and a background system. One end of the protocol server is connected to the ODBC specification interface, the other end of the protocol server is connected to the database, and the background system is also connected to the ODBC specification interface and the database. The system includes: A command judgment unit for enabling the background system to judge whether the command type included in the MYSQL protocol packet input by the ODBC specification interface is a query command; A parsing unit for judging that if so, the protocol server parses the statements included in the MYSQL protocol packet to generate a parsed statement set; A statement judgment unit for judging whether the protocol server judges that the parsed statements included in the parsed statement set are only MYSQL statements; A calling unit for judging that if so, the protocol server converts the MYSQL statements into an interface conversion parameter set for the JDBC specification interface group in the database to call and execute, thereby converting into a conversion result set; A sending unit for the database to send the conversion result set to the background system.

9. A computer device, characterized in that, It includes a memory, a processor, and a computer program stored in the memory and executable on the processor. The characteristic is that when the processor executes the computer program, it implements the ODBC specification-based command conversion method according to any one of claims 1 to 7.

10. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by the processor, it implements the steps of the ODBC specification-based command conversion method according to any one of claims 1 to 7.

Citation Information

Patent Citations

  • Cross-platform data interaction method based on virtual private network (VPN)

    CN102970205A

  • Data-integrated access device and method and storage medium

    CN109445754A