CN104636131B - A kind of execution method and device of special instruction - Google Patents

A kind of execution method and device of special instruction Download PDF

Info

Publication number
CN104636131B
CN104636131B CN201410768908.7A CN201410768908A CN104636131B CN 104636131 B CN104636131 B CN 104636131B CN 201410768908 A CN201410768908 A CN 201410768908A CN 104636131 B CN104636131 B CN 104636131B
Authority
CN
China
Prior art keywords
instruction
special
special instruction
database
relevant information
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Expired - Fee Related
Application number
CN201410768908.7A
Other languages
Chinese (zh)
Other versions
CN104636131A (en
Inventor
朱超
陈非
王超
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Qihoo Technology Co Ltd
Original Assignee
Beijing Qihoo Technology Co Ltd
Qizhi Software Beijing Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Qihoo Technology Co Ltd, Qizhi Software Beijing Co Ltd filed Critical Beijing Qihoo Technology Co Ltd
Priority to CN201410768908.7A priority Critical patent/CN104636131B/en
Publication of CN104636131A publication Critical patent/CN104636131A/en
Priority to PCT/CN2015/095543 priority patent/WO2016091068A1/en
Application granted granted Critical
Publication of CN104636131B publication Critical patent/CN104636131B/en
Expired - Fee Related legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Data Mining & Analysis (AREA)
  • Databases & Information Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

This application discloses a kind of execution method and devices of special instruction, this method middleware connects database and client, middleware sends special instruction, and record relevant information corresponding with the special instruction, when receiving the matching instruction of the special instruction, using preset sending method corresponding with the relevant information, the matching instruction is sent to database to execute, since database can correctly identify the matching instruction sent using preset sending method corresponding with the relevant information, therefore, database can also correctly execute the matching instruction.

Description

A kind of execution method and device of special instruction
Technical field
The present invention relates to field of computer technology more particularly to a kind of execution method and devices of special instruction.
Background technology
With the rapid development of internet, the middleware Technology of database is in the distributed data base system of network-oriented It is widely used.
Both middleware can be the relay device between client and database, and can connect, middleware carries The function of database connection pool is supplied.When client, which is sent by middleware to database, to be instructed, middleware connects from database It connects and an idle connection is selected to distribute to the client in pond, middleware is connected as client by this and refers to database transmission The implementing result for the instruction for enabling, and being returned to client transmission data library, then, middleware recycles the connection, as the visitor When family end subsequently sends instruction to database again, then middleware may distribute another idle connection and make to the client With.
In the prior art, for some special instructions, after database executes the special instruction, then hair can be directed to Connection used in the special instruction is given, identifies the matching instruction of the special instruction subsequently sent from the connection, and is executed. But using database connection pool, middleware is connected as client by some and sends the special instruction, then It is continuous that the matching instruction that client sends the special instruction may be connected as by another, it can not be correct so as to cause database Identify the matching instruction, therefore, database also can not correctly execute the matching instruction, wherein the instruction is structuralized query The instruction of language (Structured Query Language, SQL) statement form.
For example, special instruction can be PREPARE sentences, then the matching instruction of the PREPARE sentences includes:Carrying should Special identifier (the special identifier that PREPARE sentences are included, that is, PREPARE sentences are wrapped that PREPARE sentences are included The statement title of the templates statement contained) EXECUTE sentences or DEALLOCATE sentences.It is assumed that middleware is sent by connection 1 PREPARE sentences subsequently send corresponding EXECUTE sentences further through connection 2, then database can not correctly execute this EXECUTE sentences.
In another example special instruction can be the BEGIN statement in db transaction, then the matching instruction of the BEGIN statement Including:With other SQL statements of the BEGIN statement in the same db transaction, such as COMMIT sentences, ROLLBACK languages Sentence etc..It is assumed that middleware sends BEGIN statement by connection 1, corresponding COMMIT sentences subsequently are sent further through connection 2, then Database can not correctly execute the COMMIT sentences.
Invention content
In view of the above problems, it is proposed that the present invention overcoming the above problem in order to provide one kind or solves at least partly The execution method and device for stating the special sentence of problem, using intermediate part, it is special that database can be executed correctly The matching instruction of instruction.
According to the first aspect of the invention, a kind of execution method of special instruction is proposed, applied to being coupled in database Middleware between client, the method includes:
Special instruction is sent, and records relevant information corresponding with the special instruction, wherein the relevant information packet It includes:Send the template instruction that the special instruction uses the mark of connection and/or the special instruction to include;
Receive the matching instruction of the special instruction;
It will be described using preset sending method corresponding with the relevant information according to the relevant information of record Matching instruction is sent to database execution.
Optionally, when the relevant information uses the mark of connection by the transmission special instruction, use is preset The matching instruction is sent to database and executed, specifically included by sending method corresponding with the relevant information:
By the matching instruction by with send special instruction institute and be sent to using corresponding connect of the mark of connection Database executes.
Optionally, after sending special instruction, the method further includes:
It keeps sending used in the special instruction for the database and the client and connect.
Optionally, when the relevant information be the special instruction include template instruction when, using it is preset with it is described The matching instruction is sent to database and executed, specifically included by the corresponding sending method of relevant information:
General instruction is generated according to template instruction and the matching instruction;
The general instruction of generation is sent to database to execute.
Optionally, general instruction is generated according to template instruction and the matching instruction, specifically included:
Judge in the template instruction whether to include undetermined parameter;
If so, being the undetermined parameter assignment in the matching instruction according to the parameter value for including, by the mould after assignment Plate instruction is as the general instruction generated;
Otherwise, the template is instructed as the general instruction generated.
Optionally, described instruction includes:The instruction of structured query language SQL statement form;
When the relevant information uses the mark of connection by the transmission special instruction, the special instruction includes BEGIN statement or PREPARE sentences, when the special instruction is BEGIN statement, the matching instruction is and the BEGIN Sentence belongs to the sentence of the same db transaction, and when the special instruction is PREPARE sentences, the matching instruction is EXECUTE sentences or DEALLOCATE sentences;
When the relevant information is the template instruction that the special instruction includes, the special instruction includes PREPARE Sentence, the matching instruction include EXECUTE sentences.
According to the second aspect of the invention, it proposes a kind of executive device of special instruction, is coupled to database and client Between end, including:
First sending module for sending special instruction, and records relevant information corresponding with the special instruction, In, the relevant information includes:Send the special instruction use connection mark and/or the special instruction include Template instructs;
Receiving module, the matching instruction for receiving the special instruction;
Second sending module, for the relevant information that record according to first sending module, using preset and The matching instruction is sent to database and executed by the corresponding sending method of the relevant information.
When the relevant information uses the mark of connection by the transmission special instruction, the second sending module tool Body is used for, by the matching instruction by with send special instruction institute and be sent to number using corresponding connect of the mark of connection It is executed according to library.
Optionally, described device further includes:
Module is kept, is the database and the visitor after sending special instruction in first sending module Family end keeps first sending module to send connection used in the special instruction.
When the relevant information is the template instruction that the special instruction includes, second sending module is specifically used In generating general instruction according to template instruction and the matching instruction, general instruct of generation be sent to database It executes.
Second sending module is specifically used for, and judges whether in the template instruction include undetermined parameter, if so, root It is the undetermined parameter assignment in the matching instruction according to the parameter value for including, by the template instruction after assignment as one generated As instruct, otherwise, by the template instruction as generation general instruction.
Optionally, described instruction includes:The instruction of structured query language SQL statement form;
When the relevant information uses the mark of connection by the transmission special instruction, the special instruction includes BEGIN statement or PREPARE sentences, when the special instruction is BEGIN statement, the matching instruction is and the BEGIN Sentence belongs to the sentence of the same db transaction, and when the special instruction is PREPARE sentences, the matching instruction is EXECUTE sentences or DEALLOCATE sentences;
When the relevant information is the template instruction that the special instruction includes, the special instruction includes PREPARE Sentence, the matching instruction include EXECUTE sentences.
According to the execution method of special instruction provided by the invention, middleware sends special instruction, and record is special with this Corresponding relevant information is instructed, when receiving the matching instruction of the special instruction, using preset corresponding with the relevant information Sending method, by the matching instruction be sent to database execute, due to database can correctly identify using it is preset with should The matching instruction that the corresponding sending method of relevant information is sent, therefore, database can also correctly execute the matching instruction, solution The problem of database of having determined can not correctly execute the matching instruction.
Description of the drawings
By reading the detailed description of hereafter preferred embodiment, various other advantages and benefit are common for this field Technical staff will become clear.Attached drawing only for the purpose of illustrating preferred embodiments, and is not considered as to the present invention Limitation.And throughout the drawings, the same reference numbers will be used to refer to the same parts.In the accompanying drawings:
Fig. 1 is the flow diagram of the execution method of the special instruction of embodiment according to the present invention;
Fig. 2 is embodiment according to the present invention, under practical application scene, the connection between database, middleware, client The schematic diagram of framework;
Fig. 3 is embodiment according to the present invention, and under practical application scene, client to middleware to database by sending Special instruction and the special instruction matching instruction implementation procedure schematic diagram;
Fig. 4 is embodiment according to the present invention, under practical application scene, before client sends special instruction, and database The schematic diagram of the structure of the tables of data Student of middle storage;
Fig. 5 is that embodiment inquires under practical application scene after database execution SQL statement S4 according to the present invention The schematic diagram of corresponding data;
Fig. 6 is that embodiment inquires under practical application scene after database execution SQL statement S6 ' according to the present invention The schematic diagram of corresponding data;
Fig. 7 is the schematic diagram of the executive device of the special sentence of embodiment according to the present invention.
Specific implementation mode
The exemplary embodiment of the disclosure is more fully described below with reference to accompanying drawings.Although showing the disclosure in attached drawing Exemplary embodiment, it being understood, however, that may be realized in various forms the disclosure without should be by embodiments set forth here It is limited.On the contrary, these embodiments are provided to facilitate a more thoroughly understanding of the present invention, and can be by the scope of the present disclosure Completely it is communicated to those skilled in the art.
Below in conjunction with attached drawing, the technical solution that each embodiment of the application provides is described in detail.
Fig. 1 is the schematic diagram of the execution method of the special instruction of embodiment according to the present invention, can be applied to be coupled in number According to the middleware between library and client, the method may include steps:
S101:Special instruction is sent, and records relevant information corresponding with the special instruction.
Wherein, which includes:Send mark and/or the special instruction packet that the special instruction uses connection The template instruction contained.
S102:Receive the matching instruction of the special instruction.
S103:According to the relevant information of record, using preset sending method corresponding with the relevant information, by this Matching instruction is sent to database execution.
From the foregoing, according to the embodiment, middleware sends special instruction, and records phase corresponding with the special instruction Close information, that is, middleware often sends a special instruction, can all record relevant information corresponding with the special instruction, the correlation Information is used to determine the sending method of the matching instruction of the special instruction, therefore, for different types of special instruction, record Relevant information is also different, and for certain a kind of special instruction, the relevant information of record uses connection by the transmission special instruction Mark, for another kind of special instruction, the relevant information of record is the template instruction that the special instruction includes.Subsequently work as middleware When receiving the matching instruction of the special instruction, then according to the relevant information of record, using preset corresponding with the relevant information Sending method, which is sent to database and is executed, due to being directed to every a kind of special instruction, middleware is all set in advance The sending method for having set the matching instruction of the special instruction enables database to be correctly identified by of sending method transmission With instruction, therefore, database can correctly execute the matching instruction.
One embodiment according to the present invention, due to for certain special instructions, after database executes special instruction, It can be directed to and send connection used in the special instruction, identify that the matching of the special instruction subsequently sent from the connection refers to It enables, therefore, after middleware sends special instruction, the relevant information corresponding with the special instruction of record can be special to send this Instruction uses the mark of connection.When middleware subsequently receives the matching instruction of the special instruction from the client, then in Between part by the matching instruction by it is corresponding with the mark of record connection be sent to database execute.
Specifically, the relevant information corresponding with the special instruction when record uses connection by the transmission special instruction When mark, after middleware receives the matching instruction of the special instruction, according to the transmission of record, the special instruction uses connection When transmission special instruction then the matching instruction is sent to number by used connection by the connection before mark can determine It is executed according to library.In this way, since middleware sends special instruction and its subsequent matching instruction being sent by the same connection To database, therefore, database can correctly identify the matching instruction, so as to correct according to the same connection Execute the matching instruction.
Further, one embodiment according to the present invention, when middleware transmission special instruction, and record is special with this Instruct corresponding relevant information by the transmission special instruction using connection mark when, middleware send special instruction it Afterwards, middleware can also be that database and client keep sending connection used in the special instruction, that is, middleware will be special After instruction is sent to database by a connection, the connection is not recycled, other clients are not distributed into the connection yet It uses, therefore, when the matching instruction of the subsequently received special instruction of middleware, the connection can be used directly and send the matching Instruction improves the efficiency that middleware sends matching instruction.
One embodiment according to the present invention when middleware transmission special instruction, and records corresponding with the special instruction Relevant information by the transmission special instruction using connection mark when, the instruction is the instruction of SQL statement form, should Special instruction can be BEGIN statement (BEGIN statement, that is, the BEGIN TRANSCATION sentences in db transaction) or PREPARE sentences.
Specifically, when special instruction is BEGIN statement, then the matching instruction of the special instruction is and the BEGIN statement Belong to the sentence of the same db transaction, such as COMMIT sentences, ROLLBACK sentences.
It is illustrated below for db transaction:
One database transaction packet contains a plurality of SQL statement.One db transaction is started with BEGIN statement, and centre can Including several sentences can submit the database thing when sentence all successful executions of BEGIN statement and centre with COMMIT sentences Completed operation in business can be used when centre has sentence execution failure or the db transaction that cannot continue to execute The ROLLBACK sentences rollback db transaction is shown that is, cancelling the operation for being completed in the db transaction but not yet submitting So, a db transaction can be with COMMIT sentences or ROLLBACK Statement Completions.
Since multiple db transactions can be performed simultaneously in the database, in order not to obscure each db transaction, data Library is identified all sentences of a db transaction using connection identifier (Identity, ID), wherein the connection identifier By send the db transaction sentence use connection connection ID.If certain sentence of middleware transmission data library affairs with The other sentences for sending the db transaction have used different connections, then database thinks that this sentence belongs to other sentences Different db transactions, and it is identified with corresponding different connection IDs respectively, therefore, the database of each connection ID mark The sentence of affairs is imperfect, causes database that can not correctly execute the sentence in the db transaction.
According to the above description, database is the sentence identified according to connection in the same db transaction, and therefore, it is necessary to will Same all sentences of db transaction are sent by identical connection.Then when the relevant information of middleware record is to send special finger Enable the connection ID for use and connecting, and the special instruction for BEGIN statement when, in step S101~S103 shown in Fig. 1, in Between part send BEGIN statement, and record send the BEGIN statement use connection connection ID, when it is subsequently received and be somebody's turn to do BEGIN statement belongs to other sentences of the same db transaction, such as when COMMIT sentences, ROLLBACK sentences, by this its Its sentence is sent to database by the connection that the connection ID of record is identified and executes, then database can correctly execute other languages Sentence.
It is illustrated below for PREPARE sentences, EXECUTE sentences and DEALLOCATE sentences:
When special instruction is PREPARE sentences, the matching instruction of the special instruction be EXECUTE sentences or DEALLOCATE sentences (DEALLOCATE sentences, that is, DEALLOCATE PREPARE sentences), wherein the PREPARE sentences In include templates statement (templates statement, that is, template instruct) and the statement title of the templates statement, the EXECUTE languages It also include the statement title of the templates statement in sentence and the DEALLOCATE sentences.
PREPARE sentences state a templates statement, the statement title of the templates statement and the templates statement in advance Undetermined parameter (templates statement can not include undetermined parameter yet).When database executes PREPARE sentences, for each PREPARE sentences can be that the PREPARE sentences preserve one group of content, and use connection using the PREPARE sentences are sent Connection ID preserves content to the group and is identified, wherein the group preserves content and includes:The template for including in the PREPARE sentences The undetermined parameter of sentence, the statement title of the templates statement, the templates statement.
EXECUTE sentences contain the statement title of templates statement and the parameter value of templates statement.When database executes When EXECUTE sentences, can according to send the EXECUTE sentences to inquire the connection ID using the connection ID of connection corresponding The preservation content of PREPARE sentences, and each group inquired is preserved into the statement title of the templates statement in content and is somebody's turn to do The statement title for the templates statement for including in EXECUTE sentences is compared, if certain group preserves the sound of the templates statement in content Bright title is identical as the statement title for including in the EXECUTE sentences, then being according to the parameter value that the EXECUTE sentences include should Group preserves the undetermined parameter assignment of the templates statement in content, and executes the templates statement after assignment.
DEALLOCATE sentences contain the statement title of templates statement.When database executes DEALLOCATE sentences, Can according to send the DEALLOCATE sentences the guarantors of the corresponding PREPARE sentences of the connection ID is inquired using the connection ID of connection Content is deposited, and includes with the DEALLOCATE sentences by the statement title of the templates statement in each group inquired preservation content Templates statement statement title it is identical be compared, if the statement title of the templates statement in a certain group of preservation content with should The statement title for the templates statement for including in EXECUTE sentences is identical, then deletes the group and preserve content.
According to the above description, database be according to connection identification PREPARE sentences and corresponding EXECUTE sentences and DEALLOCATE sentences.If middleware sends PREPARE sentences, EXECUTE or DEALLOCATE sentences corresponding with transmission make With different connections, then according to transmission, the corresponding EXECUTE or DEALLOCATE sentences use the connection connected to database root ID cannot inquire the corresponding preservation content of the PREPARE sentences identified using another connection ID, not to database The corresponding EXECUTE or DEALLOCATE sentences can correctly be executed.
Therefore, it is necessary to PREPARE sentences and corresponding EXECUTE sentences and/or DEALLOCATE sentences are passed through phase It is sent with connection.One embodiment according to the present invention, when the relevant information of middleware record is used to send special instruction The connection ID of connection, and it (includes templates statement and its statement in the PREPARE sentences that the special instruction, which is PREPARE sentences, Title) when, in step S101~S103 shown in Fig. 1, middleware sends PREPARE sentences, and records and send the PREPARE Sentence use connection connection ID, when it is subsequently received include the EXECUTE sentences of the statement title and/or When DEALLOCATE sentences, the EXECUTE sentences and/or the DEALLOCATE sentences are identified by the connection ID of record Connection is sent to database execution, then database can correctly execute the EXECUTE sentences and/or the DEALLOCATE sentences.
One embodiment according to the present invention when middleware transmission special instruction, and records corresponding with the special instruction Relevant information when being the template instruction that the special instruction includes, in step S103 shown in Fig. 1, using preset and institute The corresponding sending method of relevant information is stated, which, which is sent to database, executes, and specifically includes:Referred to according to the template It enables and the matching instruction generates general instruction, the general instruction of generation, which is sent to database, to be executed.Wherein, according to the mould Plate instructs and the matching instruction generates general instruction, specifically includes:Whether comprising undetermined in middleware judges template instruction Template after assignment is instructed and is made if so, being the undetermined parameter assignment in the matching instruction according to the parameter value for including by parameter For the general instruction of generation, otherwise, the general instruction by template instruction as generation.Wherein, the instruction is SQL statement The instruction of form, the special instruction be PREPARE sentences, then the matching instruction of the special instruction be include the PREPARE languages The EXECUTE sentences of the statement title for the templates statement that sentence includes.
When the relevant information of middleware record is that the template that special instruction includes instructs, and the special instruction is PREPARE When sentence, in step S101~S103 shown in Fig. 1, middleware sends PREPARE sentences, and is directed to each PREPARE Sentence records the templates statement that the PREPARE sentences include, and middleware also needs to preserve one group of content for the PREPARE sentences, Wherein, group preservation content includes:The statement title of the templates statement, the templates statement that include in the PREPARE sentences, the mould The undetermined parameter of plate sentence.When follow-up middleware receives the EXECUTE sentences of certain client transmission, inquire as from the client The each group that the PREPARE sentences that end is sent preserve preserves content, and each group inquired is preserved the templates statement in content Statement title is compared with the statement title for including in the EXECUTE sentences, if certain group preserves the templates statement in content It states that title is identical as the statement title that the EXECUTE sentences include, in turn, judges that the templates statement that the group preserves in content is No includes undetermined parameter, if so, being the templates statement in group preservation content with the parameter value that the EXECUTE sentences include Undetermined parameter assignment, and be sent to the templates statement after assignment as general sentence (general sentence, that is, general instruction) Database executes, and otherwise, which is preserved the templates statement in content and is sent to database execution as general sentence, due to number Can directly execute the general sentence according to library, and the implementation effect of the general sentence be equivalent to the EXECUTE sentences execute effect Fruit, therefore, database correctly performs the general sentence that is, database correctly performs the EXECUTE sentences.
In conjunction with Fig. 2 to 6, the specific practical application of the execution method of special instruction of the present invention is as follows:
Fig. 2 shows under the scene for applying middleware, the link between database, middleware and client Structure.3 client C1~C3 access database by middleware, specifically, client C1~C3 is based on passing with middleware respectively Transport control protocol view (Transmission Control Protocol, TCP) foundation has communication to connect, and the database of middleware connects Meet database connection c1~c3 that Chi Zhongyou is pre-established.Wherein, database can be MySQL database, and the database connects Connecing can be that java databases connect (Java Database Connectivity, JDBC).
Fig. 3 shows the matching for the special instruction and the special instruction that client is sent by middleware to database The implementation procedure of instruction, specifically includes step:
S301:Client sends several special instructions to middleware.
It is assumed that being stored with tables of data Student (tables of data Student, hereinafter referred to as table Student), table in database Student defines 5 data item:Sno、Sname、Ssex、Sage、Sdept.To after 5 data item difference assignment to Table A Middle insertion produces a data record of table Student, 3 datas record D1~D3 is contained in current table Student, Fig. 4 shows the current structures of table Student, each data that the first row expression table Student in table Student includes , data record D1~D3 that the first row expression table table Student in table Student includes, row where certain data item with It is the value of the data item in the data record in the cell of row intersection where certain data record.
Client C1 sends SQL statement S1 to middleware:
BEGIN TRANSCATION.It means:Start a db transaction.
Client C2 sends SQL statement S2 to middleware:
PREPARE incr FROM " INSERT INTO Student (Sno, Sname, Ssex, Sage, Sdept) VALUES(,,,, CS) ".It means:The templates statement of one entitled incr of statement of pre- statement, wherein the templates statement Incr is used to be inserted into a data record into table Student.
Client C3 sends SQL statement S3 to middleware:
PREPARE info FROM“SELECT*FROM Student”.It means:One entitled info of statement of pre- statement Templates statement, wherein templates statement info be used for inquiry table Student in total data.
S302:Several special instructions are sent to data by middleware by distributing to the database connection of the client Library, and it is directed to each special instruction, record the corresponding relevant information of the special instruction.
Database connection c1 in database connection pool is distributed to client C1 by middleware, and connecting c1 by database will SQL statement S1 is sent to database, and the connection ID of database of record connection c1.It is client after middleware sends SQL statement S1 Hold C1 that database is kept to connect c1, that is, database connection c1 recycling not to be put into database connection pool or the distribution of middleware It is used to other clients.
Database connection c2 in database connection pool is distributed to client C2 by middleware, and connecting c2 by database will SQL statement S2 is sent to database, and preserves one group of relevant information of SQL statement S2, including:The mould for including in SQL statement S2 Plate sentence incr, the statement title " incr " of templates statement incr, templates statement incr four undetermined parameters " Sno, Sname, Ssex, Sage ".Wherein, templates statement incr is:
INSERT INTO Student (Sno, Sname, Ssex, Sage, Sdept) VALUES (,,,, CS).
Database connection c3 in database connection pool is distributed to client C3 by middleware, and connecting c3 by database will SQL statement S3 is sent to database, and preserves one group of relevant information of SQL statement S3, including:The mould for including in SQL statement S3 The statement title " info " of plate sentence info, templates statement info.Wherein, templates statement info is:
SELECT*FROM Student。
S303:Database executes the special instruction received from middleware, and is returned and executed to client by middleware As a result.
Database successful execution SQL statement S1, opens a db transaction, and database connects the company of c1 with database It meets ID to be identified SQL statement S1, then starts to monitor other languages from the database connection c1 db transactions sent Sentence, and the response to run succeeded is returned to client by middleware.
Database successful execution SQL statement S2, the connection ID that c2 is connected with database identify and save SQL statement S2's One group of relevant information, including:Include in SQL statement S2 templates statement incr " INSERT INTO Student (Sno, Sname, Ssex, Sage, Sdept) VALUES (,,,, ' CS ') ", statement title " incr ", the template of templates statement incr Four undetermined parameters " Sno, Sname, Ssex, the Sage " of sentence incr.Then start to monitor from database connection c2 transmissions The match statement of SQL statement S2, and the response to run succeeded is returned to client by middleware.
Database successful execution SQL statement S3, the connection ID that c3 is connected with database identify and save SQL statement S3's One group of relevant information, including:Templates statement info " SELECT*FROM Student ", the templates statement for including in SQL statement S3 The statement title " info " of info.Then start to monitor the match statement from the database connection c3 SQL statement S3 sent, and lead to It crosses middleware and returns to the response to run succeeded to client.
S304:Client sends the matching instruction of special instruction to middleware.
Client C1 sends SQL statement S4 to middleware:
SELECT Sno, Sname FROM Student Where Ssex=' men '.It means:Number in inquiry table Student According to item Ssex=' man ' data record data item Sno, Sname value.
Client C2 sends SQL statement S5 to middleware:
EXECUTE incr USING ' 20145124 ', ' Zhao six ', ' female ', 18.It means:With the parameter for including in the sentence Value is templates statement incr assignment, and executes the sentence generated after assignment.
Client C3 sends SQL statement S6 to middleware:
EXECUTE info.It means:Execute templates statement info.
S305:Middleware is preset according to special instruction, and the corresponding relevant information of the special instruction of record, use The matching instruction is sent to database by sending method.
SQL statement S4 is connected c1 by database and is sent to database by middleware.
Middleware is according to the mould that the parameter value for the templates statement for including in SQL statement S5 is that the SQL statement S2 preserved includes Plate sentence assignment generates SQL statement S5 ':
INSERT INTO Student (Sno, Sname, Ssex, Sage, Sdept) VALUES (' 20145124 ', ' Zhao Six ', ' female ', 18, ' CS ').It means:It is inserted into a data into table Student and records (Sno=' 20145124 ', Sname= ' Zhao six ', Ssex=' female ', Sage=18, Sdept=' CS ').
And the SQL statement S5 ' of generation is sent to database.
Middleware generates SQL statement S6 ' according to the templates statement that the SQL statement S3 of preservation includes:
SELECT*FROM Student.It means:Total data in inquiry table Student.
And the SQL statement S6 ' of generation is sent to database.Wherein, since the SQL statement S3 templates statements for including do not wrap Containing undetermined parameter, then the SQL statement S6 generated is the templates statement info that SQL statement S3 includes.
S306:Database executes the sentence received from middleware, and returns to implementing result to client by middleware.
Database successful execution SQL statement S4, the corresponding data that will be inquired in table Student, and run succeeded Response by middleware to client return.Wherein, Fig. 5 shows the corresponding data inquired, in table Student, number According to item Ssex=' man ' data record be D1, D2, the value of the data item Sno and Sname of D1, D2 are SQL statement S4 Query result.
Database successful execution SQL statement S5 ', a new data item D4 is inserted into table Student, and pass through centre Part returns to the response to run succeeded to client.Fig. 6 shows the knot of the table Student after database executes SQL statement S5 ' Structure, increase in table Student a new data item D4 (Sno=' 20145124 ', Sname=' Zhao six ', Ssex=' female ', Sage=18, Sdept=' CS ').
Database successful execution SQL statement S6 ', the corresponding data that will be inquired in table Student, and run succeeded Response by middleware to client return.Wherein, Fig. 6 shows the corresponding data inquired, as current table Student。
It is a kind of execution method of special instruction provided in an embodiment of the present invention above, is based on same invention thinking, this Inventive embodiments also provide a kind of executive device of special instruction, as shown in Figure 7.
Fig. 7 is the executive device structural schematic diagram of the special instruction of one embodiment according to the present invention, is specifically included:
First sending module 701 for sending special instruction, and records relevant information corresponding with the special instruction, Wherein, the relevant information includes:Send the special instruction use connection mark and/or the special instruction include Template instruction;
Receiving module 702, the matching instruction for receiving the special instruction;
Second sending module 703, the relevant information for being recorded according to first sending module 701, using pre- If sending method corresponding with the relevant information, by the matching instruction be sent to database execute.
When the relevant information uses the mark of connection by the transmission special instruction, the second sending module tool Body 703 is used for, by the matching instruction by with send the special instruction and use the corresponding connection transmission of the mark that connects It is executed to database.
Described device further includes:
Keep module 704, for first sending module 701 send special instruction after, be the database and The client keeps first sending module 701 to send connection used in the special instruction.
When the relevant information is the template instruction that the special instruction includes, second sending module 703 is specific For generating general instruction according to template instruction and the matching instruction, the general instruction of generation being sent to data Library executes.
Whether second sending module 703 is specifically used for, judge in the template instruction to include undetermined parameter, if so, It is then the undetermined parameter assignment in the matching instruction according to the parameter value for including, by the template instruction after assignment as generation General instruction, otherwise, by the template instruction as generation general instruction.
Described instruction includes:The instruction of structured query language SQL statement form;
When the relevant information uses the mark of connection by the transmission special instruction, the special instruction includes BEGIN statement or PREPARE sentences, when the special instruction is BEGIN statement, the matching instruction is and the BEGIN Sentence belongs to the sentence of the same db transaction, and when the special instruction is PREPARE sentences, the matching instruction is EXECUTE sentences or DEALLOCATE sentences;
When the relevant information is the template instruction that the special instruction includes, the special instruction includes PREPARE Sentence, the matching instruction include EXECUTE sentences.
Specifically, the executive device of above-mentioned special instruction as shown in Figure 7 can be located in middleware.
Algorithm and display be not inherently related to any certain computer, virtual system or miscellaneous equipment provided herein. Various general-purpose systems can also be used together with teaching based on this.As described above, it constructs required by this kind of system Structure be obvious.In addition, the present invention is not also directed to any certain programmed language.It should be understood that can utilize various Programming language realizes the content of invention described herein, and the description done above to language-specific is to disclose this hair Bright preferred forms.
In the instructions provided here, numerous specific details are set forth.It is to be appreciated, however, that the implementation of the present invention Example can be put into practice without these specific details.In some instances, well known method, structure is not been shown in detail And technology, so as not to obscure the understanding of this description.
Similarly, it should be understood that in order to simplify the disclosure and help to understand one or more of each inventive aspect, Above in the description of exemplary embodiment of the present invention, each feature of the invention is grouped together into single implementation sometimes In example, figure or descriptions thereof.However, the method for the disclosure should be construed to reflect following intention:It is i.e. required to protect Shield the present invention claims the more features of feature than being expressly recited in each claim.More precisely, as following Claims reflect as, inventive aspect is all features less than single embodiment disclosed above.Therefore, Thus the claims for following specific implementation mode are expressly incorporated in the specific implementation mode, wherein each claim itself All as a separate embodiment of the present invention.
Those skilled in the art, which are appreciated that, to carry out adaptively the module in the equipment in embodiment Change and they are arranged in the one or more equipment different from the embodiment.It can be the module or list in embodiment Member or component be combined into a module or unit or component, and can be divided into addition multiple submodule or subelement or Sub-component.Other than such feature and/or at least some of process or unit exclude each other, it may be used any Combination is disclosed to all features disclosed in this specification (including adjoint claim, abstract and attached drawing) and so to appoint Where all processes or unit of method or equipment are combined.Unless expressly stated otherwise, this specification (including adjoint power Profit requires, abstract and attached drawing) disclosed in each feature can be by providing the alternative features of identical, equivalent or similar purpose come generation It replaces.
In addition, it will be appreciated by those of skill in the art that although some embodiments described herein include other embodiments In included certain features rather than other feature, but the combination of the feature of different embodiments means in of the invention Within the scope of and form different embodiments.For example, in the following claims, embodiment claimed is appointed One of meaning mode can use in any combination.
The all parts embodiment of the present invention can be with hardware realization, or to run on one or more processors Software module realize, or realized with combination thereof.It will be understood by those of skill in the art that can use in practice Microprocessor or digital signal processor (DSP) realize the implantation letter in interception application program according to the ... of the embodiment of the present invention The some or all functions of some or all components in the equipment of breath.The present invention is also implemented as executing here Some or all equipment or program of device of described method are (for example, computer program and computer program production Product).It is such to realize that the program of the present invention may be stored on the computer-readable medium, or can have one or more The form of signal.Such signal can be downloaded from internet website and be obtained, and either be provided on carrier signal or to appoint What other forms provides.
It should be noted that the present invention will be described rather than limits the invention for above-described embodiment, and ability Field technique personnel can design alternative embodiment without departing from the scope of the appended claims.In the claims, Any reference mark between bracket should not be configured to limitations on claims.Word "comprising" or " comprising " are not arranged Except there are element or steps not listed in the claims.Word "a" or "an" before element does not exclude the presence of more A such element.The present invention can be by means of including the hardware of several different elements and by means of properly programmed calculating Machine is realized.In the unit claims listing several devices, several in these devices can be by same Hardware branch embodies.The use of word first, second, and third does not indicate that any sequence.It can be by these word solutions It is interpreted as title.
This application can be applied to computer system/servers, can be with numerous other general or specialized computing system rings Border or configuration operate together.Suitable for be used together with computer system/server well-known computing system, environment and/ Or the example of configuration includes but not limited to:Personal computer system, server computer system, thin client, thick client computer, hand Hold or laptop devices, microprocessor-based system, set-top box, programmable consumer electronics, NetPC Network PC, small-sized meter Calculation machine Xi Tong ﹑ large computer systems and distributed cloud computing technology environment, etc. including any of the above described system.
Computer system/server can be in computer system executable instruction (such as journey executed by computer system Sequence module) general context under describe.In general, program module may include routine, program, target program, component, logic, number According to structure etc., they execute specific task or realize specific abstract data type.Computer system/server can be with Implement in distributed cloud computing environment, in distributed cloud computing environment, task is long-range by what is be linked through a communication network Manage what equipment executed.In distributed cloud computing environment, program module can be positioned at the Local or Remote meter for including storage device It calculates in system storage medium.
The present invention includes A7, a kind of executive device of special instruction, is coupled between database and client, described device Including:
First sending module for sending special instruction, and records relevant information corresponding with the special instruction, In, the relevant information includes:Send the special instruction use connection mark and/or the special instruction include Template instructs;
Receiving module, the matching instruction for receiving the special instruction;
Second sending module, for the relevant information that record according to first sending module, using preset and The matching instruction is sent to database and executed by the corresponding sending method of the relevant information.
A8, the device as described in claim A7, which is characterized in that when the relevant information is to send the special instruction When using the mark of connection, second sending module is specifically used for, and it is described special with transmission that the matching instruction is passed through Instruction institute using connection mark it is corresponding connection be sent to database execution.
A9, the device as described in claim A8, which is characterized in that described device further includes:
Module is kept, is the database and the visitor after sending special instruction in first sending module Family end keeps first sending module to send connection used in the special instruction.
A10, the device as described in claim A7, which is characterized in that when the relevant information is the special instruction packet When the template instruction contained, second sending module is specifically used for, and is generated according to template instruction and the matching instruction The general instruction of generation is sent to database and executed by general instruction.
A11, the device as described in claim A10, which is characterized in that second sending module is specifically used for, and judges Whether include undetermined parameter in the template instruction, if so, being described wait in the matching instruction according to the parameter value for including Parameter assignment is determined, by the template instruction after assignment as the general instruction generated, otherwise, by template instruction as generation General instruction.
A12, the device as described in claim A7~A11 is any, which is characterized in that described instruction includes:Structuring is looked into Ask the instruction of language SQL statement form;
When the relevant information uses the mark of connection by the transmission special instruction, the special instruction includes BEGIN statement or PREPARE sentences, when the special instruction is BEGIN statement, the matching instruction is and the BEGIN Sentence belongs to the sentence of the same db transaction, and when the special instruction is PREPARE sentences, the matching instruction is EXECUTE sentences or DEALLOCATE sentences;
When the relevant information is the template instruction that the special instruction includes, the special instruction includes PREPARE Sentence, the matching instruction include EXECUTE sentences.

Claims (8)

1. a kind of execution method of special instruction, applied to the middleware being coupled between database and client, the method Including:
Special instruction is sent, and records corresponding with special instruction relevant information, wherein the relevant information includes:Hair The template instruction for sending the special instruction that the mark of connection and/or the special instruction is used to include;
Receive the matching instruction of the special instruction;And
According to the relevant information of record, using preset sending method corresponding with the relevant information, by the matching Instruction is sent to database execution;
Wherein, when the relevant information uses the mark of connection by the transmission special instruction, the special instruction includes BEGIN statement or PREPARE sentences, when the special instruction is BEGIN statement, the matching instruction is and the BEGIN Sentence belongs to the sentence of the same db transaction, and when the special instruction is PREPARE sentences, the matching instruction is EXECUTE sentences or DEALLOCATE sentences;
When the relevant information is the template instruction that the special instruction includes, the special instruction includes PREPARE sentences, The matching instruction includes EXECUTE sentences.
2. the method as described in claim 1, which is characterized in that when the relevant information is used by the transmission special instruction When the mark of connection, using preset sending method corresponding with the relevant information, the matching instruction is sent to data Library executes, and specifically includes:
By the matching instruction by with send special instruction institute and be sent to data using corresponding connect of the mark of connection Library executes.
3. method as claimed in claim 2, which is characterized in that after sending special instruction, the method further includes:
It keeps sending used in the special instruction for the database and the client and connect.
4. the method as described in claim 1, which is characterized in that when the relevant information is the template that the special instruction includes When instruction, using preset sending method corresponding with the relevant information, the matching instruction is sent to database and is executed, It specifically includes:
General instruction is generated according to template instruction and the matching instruction;
The general instruction of generation is sent to database to execute;
Wherein, general instruction is generated according to template instruction and the matching instruction, specifically included:
Judge in the template instruction whether to include undetermined parameter;
If so, being the undetermined parameter assignment in the matching instruction according to the parameter value for including, the template after assignment is referred to It enables as the general instruction generated;
Otherwise, the template is instructed as the general instruction generated.
5. a kind of executive device of special instruction, is coupled between database and client, described device includes:
First sending module for sending special instruction, and records relevant information corresponding with the special instruction, wherein institute Stating relevant information includes:The template that the special instruction uses the mark of connection and/or the special instruction to include is sent to refer to It enables;
Receiving module, the matching instruction for receiving the special instruction;
Second sending module, for the relevant information that is recorded according to first sending module, using it is preset with it is described The matching instruction is sent to database and executed by the corresponding sending method of relevant information;
Wherein, when the relevant information uses the mark of connection by the transmission special instruction, the special instruction includes BEGIN statement or PREPARE sentences, when the special instruction is BEGIN statement, the matching instruction is and the BEGIN Sentence belongs to the sentence of the same db transaction, and when the special instruction is PREPARE sentences, the matching instruction is EXECUTE sentences or DEALLOCATE sentences;
When the relevant information is the template instruction that the special instruction includes, the special instruction includes PREPARE sentences, The matching instruction includes EXECUTE sentences.
6. device as claimed in claim 5, which is characterized in that when the relevant information is used by the transmission special instruction When the mark of connection, second sending module is specifically used for, by the matching instruction by with send the special instruction institute Database is sent to using the corresponding connection of the mark of connection to execute.
7. device as claimed in claim 6, which is characterized in that described device further includes:
Module is kept, is the database and the client after sending special instruction in first sending module First sending module is kept to send connection used in the special instruction.
8. device as claimed in claim 5, which is characterized in that when the relevant information is the template that the special instruction includes When instruction, second sending module is specifically used for, and is referred generally to according to template instruction and matching instruction generation It enables, the general instruction of generation, which is sent to database, to be executed;
Wherein, whether second sending module is specifically used for, judge in the template instruction to include undetermined parameter, if so, It is the undetermined parameter assignment in the matching instruction according to the parameter value for including, by the template instruction after assignment as generation General instruction, otherwise, by template instruction as the general instruction generated.
CN201410768908.7A 2014-12-12 2014-12-12 A kind of execution method and device of special instruction Expired - Fee Related CN104636131B (en)

Priority Applications (2)

Application Number Priority Date Filing Date Title
CN201410768908.7A CN104636131B (en) 2014-12-12 2014-12-12 A kind of execution method and device of special instruction
PCT/CN2015/095543 WO2016091068A1 (en) 2014-12-12 2015-11-25 Method and device for executing special instruction

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201410768908.7A CN104636131B (en) 2014-12-12 2014-12-12 A kind of execution method and device of special instruction

Publications (2)

Publication Number Publication Date
CN104636131A CN104636131A (en) 2015-05-20
CN104636131B true CN104636131B (en) 2018-07-27

Family

ID=53214932

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201410768908.7A Expired - Fee Related CN104636131B (en) 2014-12-12 2014-12-12 A kind of execution method and device of special instruction

Country Status (2)

Country Link
CN (1) CN104636131B (en)
WO (1) WO2016091068A1 (en)

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104636131B (en) * 2014-12-12 2018-07-27 北京奇虎科技有限公司 A kind of execution method and device of special instruction
CN107122633B (en) * 2016-02-24 2020-05-12 阿里巴巴集团控股有限公司 Instruction execution method and device of application program
CN112241418B (en) * 2019-07-17 2023-04-18 金篆信科有限责任公司 Distributed database preprocessing method, agent layer, system and storage medium

Citations (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1567301A (en) * 2003-06-23 2005-01-19 华为技术有限公司 Method and apparatus for accessing database
CN1622528A (en) * 2003-11-26 2005-06-01 国际商业机器公司 Efficient connection pool management system and method
CN101753552A (en) * 2008-12-01 2010-06-23 鸿富锦精密工业(深圳)有限公司 Network communication system and method
CN102750384A (en) * 2012-06-28 2012-10-24 用友软件股份有限公司 Device and method for acquiring data from multidatabase engine
CN103365929A (en) * 2012-04-10 2013-10-23 阿里巴巴集团控股有限公司 Management method and management system of database connection
CN103544284A (en) * 2013-10-25 2014-01-29 北京奇虎科技有限公司 System and method for correcting character encoding
CN103559204A (en) * 2013-10-08 2014-02-05 北京奇虎科技有限公司 Database operation request processing method, unit and system
CN103761240A (en) * 2013-12-12 2014-04-30 北京奇虎科技有限公司 Database access method and database access device
CN103810203A (en) * 2012-11-13 2014-05-21 深圳市腾讯计算机***有限公司 Connection multiplexing method and connection multiplexing device for database management system
US8874609B1 (en) * 2010-08-10 2014-10-28 Scalarc Inc Method and system for transparent database connection pooling and query queuing

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1282919C (en) * 2002-08-23 2006-11-01 梁国恩 Intermedium software tool for server access SQL data base
CN102156720A (en) * 2011-03-28 2011-08-17 中国人民解放军国防科学技术大学 Method, device and system for restoring data
CN103678632A (en) * 2013-12-19 2014-03-26 成都市卓睿科技有限公司 System and method for updating data fast in data system
CN104636131B (en) * 2014-12-12 2018-07-27 北京奇虎科技有限公司 A kind of execution method and device of special instruction

Patent Citations (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1567301A (en) * 2003-06-23 2005-01-19 华为技术有限公司 Method and apparatus for accessing database
CN1622528A (en) * 2003-11-26 2005-06-01 国际商业机器公司 Efficient connection pool management system and method
CN101753552A (en) * 2008-12-01 2010-06-23 鸿富锦精密工业(深圳)有限公司 Network communication system and method
US8874609B1 (en) * 2010-08-10 2014-10-28 Scalarc Inc Method and system for transparent database connection pooling and query queuing
CN103365929A (en) * 2012-04-10 2013-10-23 阿里巴巴集团控股有限公司 Management method and management system of database connection
CN102750384A (en) * 2012-06-28 2012-10-24 用友软件股份有限公司 Device and method for acquiring data from multidatabase engine
CN103810203A (en) * 2012-11-13 2014-05-21 深圳市腾讯计算机***有限公司 Connection multiplexing method and connection multiplexing device for database management system
CN103559204A (en) * 2013-10-08 2014-02-05 北京奇虎科技有限公司 Database operation request processing method, unit and system
CN103544284A (en) * 2013-10-25 2014-01-29 北京奇虎科技有限公司 System and method for correcting character encoding
CN103761240A (en) * 2013-12-12 2014-04-30 北京奇虎科技有限公司 Database access method and database access device

Also Published As

Publication number Publication date
WO2016091068A1 (en) 2016-06-16
CN104636131A (en) 2015-05-20

Similar Documents

Publication Publication Date Title
Erder et al. Continuous architecture: sustainable architecture in an agile and cloud-centric world
CN110134499A (en) Method for scheduling task, task scheduling system, storage medium and computer equipment
CN113112029A (en) Federal learning system and method applied to heterogeneous computing equipment
CN111066039A (en) Microprocessor including enterprise model
CN104636131B (en) A kind of execution method and device of special instruction
Hu et al. Service net algebra based on logic Petri nets
Chang et al. Enabling technologies and platforms to aid digitalization of commercial aviation support, maintenance and health management
Song et al. Preserving data flow correctness in process adaptation
Li et al. Digital Platform Ecosystem Dynamics: The Roles of Product Scope, Innovation, and Collaborative Network Centrality.
Zhang et al. Research and development of off-line services for the 3D automatic printing machine based on cloud manufacturing
Qasim et al. Formal specification and verification of real-time multiagent systems using timed-arc petri nets
Schmidt et al. Programming Elastic MapReduce: Using AWS Services to Build an End-to-end Application
Devi et al. A model for information integration using service oriented architecture
US11782747B2 (en) System and method for notebook processing to handle job execution in cross-cloud environment
Tissot et al. An integrated enterprise modeling environment
Nanda et al. Workflow Automation of Routing Rules in the Accounting Process for Online Travel Agency
Mo et al. Development of private processes: a refinement approach
Spaulding et al. Systems engineering for complex information systems in a federated, rapid development environment
Zhang et al. Development of system life cycle processes standardization and future evolution analysis
Morales Specifying BPMN diagrams with Timed Automata: Proposal of some mapping rules
US10936378B1 (en) System and method for automating integration process building between multiple applications using integration assistance robots
US20240112067A1 (en) Managed solver execution using different solver types
Brandvold et al. Setup and operation of an e-learning platform
Leal Castillo Investigating Open Source Transformer Techniques for Question Answering Systems on Cloud Domain: A Comparison with ChatGPT3. 5-Turbo
Healy et al. Bid-centric cloud service provisioning

Legal Events

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

Effective date of registration: 20220729

Address after: Room 801, 8th floor, No. 104, floors 1-19, building 2, yard 6, Jiuxianqiao Road, Chaoyang District, Beijing 100015

Patentee after: BEIJING QIHOO TECHNOLOGY Co.,Ltd.

Address before: 100088 room 112, block D, 28 new street, new street, Xicheng District, Beijing (Desheng Park)

Patentee before: BEIJING QIHOO TECHNOLOGY Co.,Ltd.

Patentee before: Qizhi software (Beijing) Co.,Ltd.

CF01 Termination of patent right due to non-payment of annual fee
CF01 Termination of patent right due to non-payment of annual fee

Granted publication date: 20180727