CN104636131A - Special instruction execution method and device - Google Patents

Special instruction execution method and device Download PDF

Info

Publication number
CN104636131A
CN104636131A CN201410768908.7A CN201410768908A CN104636131A CN 104636131 A CN104636131 A CN 104636131A CN 201410768908 A CN201410768908 A CN 201410768908A CN 104636131 A CN104636131 A CN 104636131A
Authority
CN
China
Prior art keywords
instruction
statement
database
special instruction
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.)
Granted
Application number
CN201410768908.7A
Other languages
Chinese (zh)
Other versions
CN104636131B (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
Active 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

The invention discloses a special instruction execution method and device. According to the method, middleware is connected with a database and a client-side, the middleware sends a special instruction and records related information corresponding to the special instruction, a matched instruction is sent to the database to be executed in the preset sending mode corresponding to the related information when the matched instruction of the special instruction is received, and the database can correctly execute the matched instruction due to the fact that the database can correctly recognize the matched instruction sent in the preset sending mode corresponding to the related information.

Description

A kind of manner of execution of special instruction and device
Technical field
The present invention relates to field of computer technology, particularly relate to a kind of manner of execution and device of special instruction.
Background technology
Along with developing rapidly of internet, the middleware Technology of database is widely used in the distributed data base system of network-oriented.
Middleware can be the transferring equipment between client and database, and can connect both, and middleware provides the function of database connection pool.When client sends instruction by middleware to database, middleware selects an idle connection to distribute to this client from database connection pool, middleware is that client sends instruction to database by this connection, and the execution result of this instruction that database returns is sent to client, then, this connection is reclaimed by middleware, when this client is follow-up send instruction to database again time, then middleware may distribute the connection of another free time and uses to this client.
In the prior art, for some special instructions, after database performs this special instruction, then can for sending the connection that use of this special instruction, identify the matching instruction of follow-up this special instruction sent from this connection, and perform.But, when usage data storehouse connection pool, middleware connects for client sends this special instruction by certain, and follow-uply may connect for client sends the matching instruction of this special instruction by another, thus cause database cannot correctly identify this matching instruction, therefore, database also cannot correctly perform this matching instruction, wherein said instruction is the instruction of Structured Query Language (SQL) (Structured Query Language, SQL) statement form.
Such as, special instruction can be PREPARE statement, then the matching instruction of this PREPARE statement comprises: carry the special identifier (special identifier that PREPARE statement comprises that this PREPARE statement comprises, also namely, the statement title of templates statement that comprises of PREPARE statement) EXECUTE statement or DEALLOCATE statement.Assuming that middleware passes through connection 1 send PREPARE statement, the follow-up EXECUTE statement being sent again correspondence by connection 2, then database correctly cannot perform this EXECUTE statement.
Again such as, special instruction can be the BEGIN statement in db transaction, then the matching instruction of this BEGIN statement comprises: with other the SQL statement of this BEGIN statement in same db transaction, as COMMIT statement, ROLLBACK statement etc.Assuming that middleware passes through connection 1 send BEGIN statement, the follow-up COMMIT statement being sent again correspondence by connection 2, then database correctly cannot perform this COMMIT statement.
Summary of the invention
In view of the above problems, propose the present invention to provide a kind of overcoming the problems referred to above or the manner of execution of special sentence solved the problem at least in part and device, in use when part, database correctly can perform the matching instruction of special instruction.
According to a first aspect of the invention, propose a kind of manner of execution of special instruction, be applied to the middleware be coupled between database and client, described method comprises:
Send special instruction, and the record relevant information corresponding with described special instruction, wherein, described relevant information comprises: send described special instruction use the mark of connection and/or the template instruction that described special instruction comprises;
Receive the matching instruction of described special instruction;
According to the described relevant information of record, adopt the send mode corresponding with described relevant information preset, send to database to perform described matching instruction.
Alternatively, when described relevant information use to by the described special instruction of the transmission mark of connection, adopt the send mode corresponding with described relevant information preset, send to database to perform described matching instruction, specifically comprise:
By described matching instruction by with transmission described special instruction use connection corresponding to the mark of connection to send to database to perform.
Alternatively, after sending special instruction, described method also comprises:
For the connection that described database and described client keep the described special instruction of transmission to use.
Alternatively, when described relevant information be described special instruction comprise template instruction time, adopt preset the send mode corresponding with described relevant information, send to database to perform described matching instruction, specifically comprise:
According to described template instruction, and described matching instruction generates general instruction;
Database is sent to perform the general instruction generated.
Alternatively, generate general instruction according to described template instruction and described matching instruction, specifically comprise:
Judge whether comprise undetermined parameter in described template instruction;
If so, be then described undetermined parameter assignment according to the parameter value comprised in described matching instruction, using the template instruction after assignment as the general instruction generated;
Otherwise, using described template instruction as the general instruction generated.
Alternatively, described instruction comprises: the instruction of Structured Query Language (SQL) SQL statement form;
When described relevant information use to by the described special instruction of the transmission mark of connection, described special instruction comprises BEGIN statement or PREPARE statement, when described special instruction is BEGIN statement, described matching instruction is the statement belonging to same db transaction with described BEGIN statement, when described special instruction is PREPARE statement, described matching instruction is EXECUTE statement or DEALLOCATE statement;
When described relevant information be described special instruction comprise template instruction time, described special instruction comprises PREPARE statement, and described matching instruction comprises EXECUTE statement.
According to a second aspect of the invention, propose a kind of actuating unit of special instruction, be coupled between database and client, comprise:
First sending module, for sending special instruction, and the record relevant information corresponding with described special instruction, wherein, described relevant information comprises: send described special instruction use the mark of connection and/or the template instruction that described special instruction comprises;
Receiver module, for receiving the matching instruction of described special instruction;
Second sending module, for the described relevant information according to described first sending module record, adopts the send mode corresponding with described relevant information preset, sends to database to perform described matching instruction.
When described relevant information use to by the described special instruction of the transmission mark of connection, described second sending module specifically for, by described matching instruction by with the described special instruction of transmission use connection corresponding to the mark of connection to send to database to perform.
Alternatively, described device also comprises:
Keeping module, for sending after special instruction at described first sending module, is the connection used that keeps described first sending module to send described special instruction of described database and described client.
When described relevant information be described special instruction comprise template instruction time, described second sending module specifically for, according to described template instruction, and described matching instruction generates general instruction, by generate general instruction send to database to perform.
Described second sending module specifically for, judge whether comprise undetermined parameter in described template instruction, if, be then described undetermined parameter assignment according to the parameter value comprised in described matching instruction, using the template instruction after assignment as the general instruction generated, otherwise, using described template instruction as the general instruction generated.
Alternatively, described instruction comprises: the instruction of Structured Query Language (SQL) SQL statement form;
When described relevant information use to by the described special instruction of the transmission mark of connection, described special instruction comprises BEGIN statement or PREPARE statement, when described special instruction is BEGIN statement, described matching instruction is the statement belonging to same db transaction with described BEGIN statement, when described special instruction is PREPARE statement, described matching instruction is EXECUTE statement or DEALLOCATE statement;
When described relevant information be described special instruction comprise template instruction time, described special instruction comprises PREPARE statement, and described matching instruction comprises EXECUTE statement.
According to the manner of execution of special instruction provided by the invention, middleware sends special instruction, and the relevant information that record is corresponding with this special instruction, when receiving the matching instruction of this special instruction, adopt the send mode corresponding with this relevant information preset, database is sent to perform this matching instruction, because database correctly can identify this matching instruction adopting the send mode corresponding with this relevant information preset to send, therefore, database also can correctly perform this matching instruction, solves the problem that database correctly cannot perform this matching instruction.
Accompanying drawing explanation
By reading hereafter detailed description of the preferred embodiment, various other advantage and benefit will become cheer and bright for those of ordinary skill in the art.Accompanying drawing only for illustrating the object of preferred implementation, and does not think limitation of the present invention.And in whole accompanying drawing, represent identical parts by identical reference symbol.In the accompanying drawings:
Fig. 1 is the schematic flow sheet of the manner of execution of the special instruction of the foundation embodiment of the present invention;
Fig. 2 is according to the embodiment of the present invention, under practical application scene, and the schematic diagram of the connection framework between database, middleware, client;
Fig. 3 is according to the embodiment of the present invention, under practical application scene, and the special instruction of client by sending to middleware to database, and the schematic diagram of the implementation of the matching instruction of this special instruction;
Fig. 4 is according to the embodiment of the present invention, under practical application scene, before client sends special instruction, and the schematic diagram of the structure of the tables of data Student stored in database;
Fig. 5 is according to the embodiment of the present invention, under practical application scene, and the schematic diagram of the corresponding data that database inquires after performing SQL statement S4;
Fig. 6 is according to the embodiment of the present invention, under practical application scene, and the schematic diagram of the corresponding data that database inquires after performing SQL statement S6 ';
Fig. 7 is the schematic diagram of the actuating unit of the special sentence of the foundation embodiment of the present invention.
Embodiment
Below with reference to accompanying drawings exemplary embodiment of the present disclosure is described in more detail.Although show exemplary embodiment of the present disclosure in accompanying drawing, however should be appreciated that can realize the disclosure in a variety of manners and not should limit by the embodiment set forth here.On the contrary, provide these embodiments to be in order to more thoroughly the disclosure can be understood, and complete for the scope of the present disclosure can be conveyed to those skilled in the art.
Below in conjunction with accompanying drawing, describe the technical scheme that each embodiment of the application provides in detail.
Fig. 1 is the schematic diagram of the manner of execution of the special instruction of the foundation embodiment of the present invention, and it can be applicable to the middleware be coupled between database and client, and described method can comprise step:
S101: send special instruction, and the relevant information that record is corresponding with this special instruction.
Wherein, this relevant information comprises: send this special instruction use the mark of connection and/or the template instruction that this special instruction comprises.
S102: the matching instruction receiving this special instruction.
S103: according to this relevant information of record, adopts the send mode corresponding with described relevant information preset, sends to database to perform this matching instruction.
From the foregoing, according to this embodiment, middleware sends special instruction, and the relevant information that record is corresponding with this special instruction, namely, middleware often sends a special instruction, the relevant information that capital record is corresponding with this special instruction, this relevant information is for determining the send mode of the matching instruction of this special instruction, therefore, for dissimilar special instruction, the relevant information of record is also different, for a certain class special instruction, the mark of the relevant information of record use to by this special instruction of transmission connection, for another kind of special instruction, the relevant information of record is the template instruction that this special instruction comprises.It is follow-up when middleware receives the matching instruction of this special instruction, then according to the relevant information of record, adopt the send mode corresponding with this relevant information preset, database is sent to perform this matching instruction, due to for each class special instruction, middleware all pre-sets the send mode of the matching instruction of this special instruction, the matching instruction enabling database correctly be identified by this send mode to send, therefore, database can correctly perform this matching instruction.
According to one embodiment of the present of invention, due to for some special instruction, after database performs special instruction, the connection that can use for this special instruction of transmission, identify the matching instruction of follow-up this special instruction sent from this connection, therefore, middleware sends after special instruction, the relevant information corresponding with this special instruction of record can for send this special instruction use the mark of connection.When middleware is follow-up receive the matching instruction of this special instruction from this client time, then middleware by this matching instruction by sending to database to perform with the connection corresponding to mark of record.
Concrete, when the relevant information corresponding with this special instruction recorded use to by this special instruction of the transmission mark of connection, after middleware receives the matching instruction of this special instruction, according to this special instruction of transmission of record use the mark of connection can determine before send special instruction time the connection that uses, then, database is sent to perform by this connection this matching instruction.Like this, because middleware transmission special instruction and follow-up matching instruction thereof all send to database by same connection, therefore, database can according to this same connection, and correct identifies this matching instruction, thus this matching instruction of execution that can be correct.
Further, according to one embodiment of the present of invention, when middleware sends special instruction, and the relevant information corresponding with this special instruction of record is this special instruction of transmission when using the mark of connection, after middleware sends special instruction, middleware also can be database and client and keeps sending the connection that this special instruction uses, also be, after special instruction is sent to database by a connection by middleware, do not reclaim this connection, also the client this connection not being distributed to other uses, therefore, when the matching instruction of middleware this special instruction subsequently received, this connection can be directly used to send this matching instruction, improve the efficiency that middleware sends matching instruction.
According to one embodiment of the present of invention, when middleware sends special instruction, and the relevant information corresponding with this special instruction of record is this special instruction of transmission when using the mark of connection, described instruction is the instruction of SQL statement form, this special instruction can be BEGIN statement (BEGIN statement, also namely, the BEGIN TRANSCATION statement in db transaction) or PREPARE statement.
Concrete, when special instruction is BEGIN statement, then the matching instruction of this special instruction is the statement belonging to same db transaction with this BEGIN statement, as COMMIT statement, ROLLBACK statement etc.
Be described for db transaction below:
A database transaction packet contains many SQL statement.A db transaction starts with BEGIN statement, centre can comprise some statements, when BEGIN statement and middle statement all successful execution time, completed operation in this db transaction submitted in available COMMIT statement, when centre has statement to perform unsuccessfully or this db transaction can not continue to perform, this db transaction of available ROLLBACK statement rollback, also be, cancel in this db transaction and completed but the operation not yet submitted to, obviously, a db transaction can with COMMIT statement or ROLLBACK Statement Completion.
Owing to can perform multiple db transaction in a database simultaneously, in order to not obscure each db transaction, database uses connection identifier (Identity, ID) all statements of a db transaction are identified, wherein, this connection identifier statement that is this db transaction of transmission use the connection ID of connection.If certain statement that middleware sends db transaction employs different connection from other statement sending this db transaction, then database thinks that other statement of this statement and this belongs to different db transactions, and by corresponding different connection ID, it is identified respectively, therefore, the statement of the db transaction of each connection ID mark is all imperfect, causes database correctly cannot perform statement in this db transaction.
According to the above description, database is according to the statement in the same db transaction of linkage identification, therefore, needs all for same db transaction statements to be sent by identical connection.Then when the relevant information of middleware record be send special instruction use the connection ID of connection, and this special instruction is when being BEGIN statement, in the step S101 shown in Fig. 1 ~ S103, middleware sends BEGIN statement, and record send this BEGIN statement use the connection ID of connection, when subsequently received other statement belonging to same db transaction with this BEGIN statement, as COMMIT statement, during ROLLBACK statement etc., database is sent to perform the connection that this other statement is identified by the connection ID of record, then database correctly can perform this other statement.
Be described for PREPARE statement, EXECUTE statement and DEALLOCATE statement below:
When special instruction is PREPARE statement, the matching instruction of this special instruction is EXECUTE statement or DEALLOCATE statement (DEALLOCATE statement, also be, DEALLOCATE PREPARE statement), wherein, in this PREPARE statement, include templates statement (templates statement, also be, template instruction), and the statement title of this templates statement, also includes the statement title of this templates statement in this EXECUTE statement and this DEALLOCATE statement.
PREPARE statement states the statement title of a templates statement, this templates statement in advance, and the undetermined parameter of this templates statement (this templates statement also can not comprise undetermined parameter).When database performs PREPARE statement, for each PREPARE statement, one group of content can be preserved for this PREPARE statement, and adopt send this PREPARE statement institute use the connection ID of connection to this group preservation content identify, wherein, this group preservation content comprises: the undetermined parameter of the templates statement comprised in this PREPARE statement, the statement title of this templates statement, this templates statement.
EXECUTE statement contains the statement title of templates statement, and the parameter value of templates statement.When database performs EXECUTE statement, can according to transmission this EXECUTE statement use the connection ID of connection to inquire about the preservation content of PREPARE statement corresponding to this connection ID, and the statement title of the templates statement comprised in the statement title of the templates statement in each group that inquires preservation content and this EXECUTE statement is compared, if the statement title that certain group preserves the templates statement in content is identical with the statement title comprised in this EXECUTE statement, the parameter value then comprised according to this EXECUTE statement is the undetermined parameter assignment that this group preserves the templates statement in content, and perform this templates statement after assignment.
DEALLOCATE statement contains the statement title of templates statement.When database performs DEALLOCATE statement, can according to transmission this DEALLOCATE statement use the connection ID of connection to inquire about the preservation content of PREPARE statement corresponding to this connection ID, and compare identical with the statement title of the templates statement comprised in this DEALLOCATE statement for the statement title of the templates statement in each group that inquires preservation content, if a certain group of statement title of preserving the templates statement in content is identical with the statement title of the templates statement comprised in this EXECUTE statement, then deletes this group and preserve content.
According to the above description, database is according to linkage identification PREPARE statement, and the EXECUTE statement of correspondence and DEALLOCATE statement.If EXECUTE or the DEALLOCATE statement that middleware sends PREPARE statement corresponding from transmission employs different connection, then database root according to send this correspondence EXECUTE or DEALLOCATE statement use the connection ID of connection, just can not inquire the preservation content using this PREPARE statement of another connection ID mark corresponding, thus database correctly can not perform EXECUTE or the DEALLOCATE statement of this correspondence.
Therefore, need PREPARE statement, and the EXECUTE statement of correspondence and/or DEALLOCATE statement are by identical connections transmission.According to one embodiment of the present of invention, when the relevant information of middleware record be send special instruction use the connection ID of connection, and this special instruction is when being PREPARE statement (include in this PREPARE statement templates statement and statement title), in the step S101 shown in Fig. 1 ~ S103, middleware sends PREPARE statement, and record send this PREPARE statement use the connection ID of connection, when subsequently received include EXECUTE statement and/or the DEALLOCATE statement of this statement title time, database is sent to perform the connection that this EXECUTE statement and/or this DEALLOCATE statement are identified by the connection ID of record, then database correctly can perform this EXECUTE statement and/or this DEALLOCATE statement.
According to one embodiment of the present of invention, when middleware sends special instruction, and during the template instruction that the relevant information corresponding with this special instruction of record is described special instruction to be comprised, in the step S103 shown in Fig. 1, adopt the send mode corresponding with described relevant information preset, send to database to perform this matching instruction, specifically comprise: according to this template instruction, and this matching instruction generates general instruction, database is sent to perform the general instruction generated.Wherein, according to this template instruction, and this matching instruction generates general instruction, specifically comprise: in this template instruction of middleware judges, whether comprise undetermined parameter, if so, be then this undetermined parameter assignment according to the parameter value comprised in this matching instruction, using the template instruction after assignment as the general instruction generated, otherwise, using this template instruction as the general instruction generated.Wherein, described instruction is the instruction of SQL statement form, and this special instruction is PREPARE statement, then the matching instruction of this special instruction is the EXECUTE statement of the statement title including the templates statement that this PREPARE statement comprises.
When the relevant information of middleware record is the template instruction that special instruction comprises, and this special instruction is when being PREPARE statement, in the step S101 shown in Fig. 1 ~ S103, middleware sends PREPARE statement, and for each PREPARE statement, record the templates statement that this PREPARE statement comprises, middleware also needs for one group of content preserved in this PREPARE statement, wherein, this group preservation content comprises: the undetermined parameter of the templates statement comprised in this PREPARE statement, the statement title of this templates statement, this templates statement.When follow-up middleware receives the EXECUTE statement of certain client transmission, the each group of preservation content that inquiry is preserved for the PREPARE statement sent from this client, and the statement title comprised in the statement title of the templates statement in each group that inquires preservation content and this EXECUTE statement is compared, if the statement title that certain group preserves the templates statement in content is identical with the statement title that this EXECUTE statement comprises, and then, judge whether the templates statement that this group is preserved in content comprises undetermined parameter, if, it is then the undetermined parameter assignment of the templates statement in this group preservation content with the parameter value that this EXECUTE statement comprises, and using this templates statement after assignment as general statement (general statement, also be, general instruction) send to database to perform, otherwise, database is sent to perform as general statement the templates statement that this group is preserved in content, because database directly can perform this general statement, and the implementation effect of this general statement is equivalent to the implementation effect of this EXECUTE statement, therefore, database correctly performs this general statement and is namely equivalent to database and correctly performs this EXECUTE statement.
Composition graphs 2 to 6, the concrete practical application of the manner of execution of special instruction of the present invention is as follows:
Fig. 2 shows under the scene applying middleware, the connection framework between database, middleware and client.3 client C1 ~ C3 are by middleware accessing database, concrete, client C1 ~ C3 respectively with middleware based on transmission control protocol (Transmission Control Protocol, TCP) foundation has communication to connect, and has the DataBase combining c1 ~ c3 set up in advance in the database connection pool of middleware.Wherein, database can be MySQL database, and described DataBase combining can be java DataBase combining (Java Database Connectivity, JDBC).
Fig. 3 shows the special instruction that client is sent to database by middleware, and the implementation of the matching instruction of this special instruction, specifically comprises step:
S301: client sends some special instructions to middleware.
Store tables of data Student (tables of data Student, hereinafter referred to as table Student) in assumption database, table Student defines 5 data item: Sno, Sname, Ssex, Sage, Sdept.Insert in Table A after these 5 data item respectively assignment, a data record of table Student can be generated, 3 data record D1 ~ D3 are contained in current table Student, Fig. 4 shows the current structure of table Student, each data item that the first row expression table Student in table Student comprises, data record D1 ~ D3 that first row expression table table Student in table Student comprises is the value of this data item in this data record in the cell of the row at certain data item place and the row intersection at certain data record place.
Client C1 sends SQL statement S1 to middleware:
BEGIN TRANSCATION。Mean: 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)”。Mean: pre-one, statement statement name is called the templates statement of incr, wherein, this templates statement incr is used for inserting a data record in table Student.
Client C3 sends SQL statement S3 to middleware:
PREPARE info FROM“SELECT*FROM Student”。Mean: pre-one, statement statement name is called the templates statement of info, and wherein, this templates statement info is used for the total data in question blank Student.
S302: this some special instruction is sent to database by the DataBase combining distributing to this client by middleware, and for each special instruction, records the relevant information that this special instruction is corresponding.
DataBase combining c1 in database connection pool is distributed to client C1 by middleware, by DataBase combining c1, SQL statement S1 is sent to database, and database of record connects the connection ID of c1.After middleware sends SQL statement S1, for client C1 keeps DataBase combining c1, DataBase combining c1 is not reclaimed the database connection pool putting into middleware or distribute to other client and use yet.
DataBase combining c2 in database connection pool is distributed to client C2 by middleware, by DataBase combining c2, SQL statement S2 is sent to database, and preserve one group of relevant information of SQL statement S2, comprise: the statement title " incr " of the templates statement incr comprised in SQL statement S2, templates statement incr, four undetermined parameters " Sno; Sname; Ssex, Sage " of templates statement incr.Wherein, templates statement incr is:
INSERT INTO Student(Sno,Sname,Ssex,Sage,Sdept)VALUES(?,?,?,?,CS)。
DataBase combining c3 in database connection pool is distributed to client C3 by middleware, by DataBase combining c3, SQL statement S3 is sent to database, and preserve one group of relevant information of SQL statement S3, comprising: the statement title " info " of the templates statement info comprised in SQL statement S3, templates statement info.Wherein, templates statement info is:
SELECT*FROM Student。
S303: database performs the special instruction received from middleware, and returns execution result by middleware to client.
Database successful execution SQL statement S1, open a db transaction, the connection ID of database DataBase combining c1 identifies SQL statement S1, then start other statement monitoring this db transaction sent from DataBase combining c1, and returned the response run succeeded by middleware to client.
Database successful execution SQL statement S2, identifies by the connection ID of DataBase combining c2 and saves one group of relevant information of SQL statement S2, comprising: the templates statement incr that comprises in SQL statement S2 " INSERT INTO Student (Sno; Sname, Ssex, Sage; Sdept) VALUES (?;?,?,? ' CS ') ", the statement title " incr " of templates statement incr, four undetermined parameter " Sno of templates statement incr, Sname, Ssex, Sage ".Then start the match statement monitoring the SQL statement S2 sent from DataBase combining c2, and returned the response run succeeded by middleware to client.
Database successful execution SQL statement S3, identify by the connection ID of DataBase combining c3 and save one group of relevant information of SQL statement S3, comprising: the templates statement info " SELECT*FROM Student " comprised in SQL statement S3, the statement title " info " of templates statement info.Then start the match statement monitoring the SQL statement S3 sent from DataBase combining c3, and returned the response run succeeded by middleware 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=' man '.Mean: in question blank Student data item Ssex=' man ' the data item Sno of data record, the value of Sname.
Client C2 sends SQL statement S5 to middleware:
EXECUTE incr USING ' 20145124 ', ' Zhao six ', ' female ', 18.Mean: be templates statement incr assignment with the parameter value comprised in this statement, and the statement generated after performing assignment.
Client C3 sends SQL statement S6 to middleware:
EXECUTE info。Mean: perform templates statement info.
S305: middleware is according to special instruction, and the relevant information that this special instruction of record is corresponding, uses default send mode that this matching instruction is sent to database.
SQL statement S4 is sent to database by DataBase combining c1 by middleware.
Middleware is the templates statement assignment that the SQL statement S2 preserved comprises according to the parameter value of the templates statement comprised in SQL statement S5, generates SQL statement S5 ':
INSERT INTO Student (Sno, Sname, Ssex, Sage, Sdept) VALUES (' 20145124 ', ' Zhao six ', ' female ', 18, ' CS ').Mean: in table Student, insert data record (Sno=' 20145124 ', Sname=' Zhao six ', Ssex=' female ', Sage=18, Sdept=' CS ').
And the SQL statement S5 ' generated is sent to database.
The templates statement that middleware comprises according to the SQL statement S3 preserved generates SQL statement S6 ':
SELECT*FROM Student。Mean: the total data in question blank Student.
And the SQL statement S6 ' generated is sent to database.Wherein, the templates statement comprised due to SQL statement S3 does not comprise undetermined parameter, then the SQL statement S6 generated is the templates statement info that SQL statement S3 comprises.
S306: database performs the statement received from middleware, and returns execution result by middleware to client.
Database successful execution SQL statement S4, by the corresponding data inquired in table Student, and the response run succeeded is returned to client by middleware.Wherein, Fig. 5 shows the corresponding data inquired, table Student in, data item Ssex=' man ' data be recorded as D1, D2, the data item Sno of D1, D2 and the value of Sname are the Query Result of SQL statement S4.
Database successful execution SQL statement S5 ', is inserted a new data item D4, and is returned the response run succeeded by middleware to client in table Student.Fig. 6 shows the structure of table Student after database performs SQL statement S5 ', a new data item D4 (Sno=' 20145124 ', Sname=' Zhao six ', Ssex=' female ' is added in table Student, Sage=18, Sdept=' CS ').
Database successful execution SQL statement S6 ', by the corresponding data inquired in table Student, and the response run succeeded is returned to client by middleware.Wherein, Fig. 6 shows the corresponding data inquired, and is current table Student.
The manner of execution of a kind of special instruction provided for the embodiment of the present invention above, based on same invention thinking, the embodiment of the present invention also provides a kind of actuating unit of special instruction, as shown in Figure 7.
Fig. 7 is the actuating unit structural representation of the special instruction according to one embodiment of the invention, specifically comprises:
First sending module 701, for sending special instruction, and the record relevant information corresponding with described special instruction, wherein, described relevant information comprises: send described special instruction use the mark of connection and/or the template instruction that described special instruction comprises;
Receiver module 702, for receiving the matching instruction of described special instruction;
Second sending module 703, for the described relevant information recorded according to described first sending module 701, adopts the send mode corresponding with described relevant information preset, sends to database to perform described matching instruction.
When described relevant information use to by the described special instruction of the transmission mark of connection, described second sending module concrete 703 for, by described matching instruction by with the described special instruction of transmission use connection corresponding to the mark of connection to send to database to perform.
Described device also comprises:
Keeping module 704, after sending special instruction at described first sending module 701, is the connection used that keeps described first sending module 701 to send described special instruction of described database and described client.
When described relevant information be described special instruction comprise template instruction time, described second sending module 703 specifically for, according to described template instruction, and described matching instruction generates general instruction, by generate general instruction send to database to perform.
Described second sending module 703 specifically for, judge whether comprise undetermined parameter in described template instruction, if, be then described undetermined parameter assignment according to the parameter value comprised in described matching instruction, using the template instruction after assignment as the general instruction generated, otherwise, using described template instruction as the general instruction generated.
Described instruction comprises: the instruction of Structured Query Language (SQL) SQL statement form;
When described relevant information use to by the described special instruction of the transmission mark of connection, described special instruction comprises BEGIN statement or PREPARE statement, when described special instruction is BEGIN statement, described matching instruction is the statement belonging to same db transaction with described BEGIN statement, when described special instruction is PREPARE statement, described matching instruction is EXECUTE statement or DEALLOCATE statement;
When described relevant information be described special instruction comprise template instruction time, described special instruction comprises PREPARE statement, and described matching instruction comprises EXECUTE statement.
Concrete, the actuating unit of above-mentioned special instruction as shown in Figure 7 can be arranged in middleware.
Intrinsic not relevant to any certain computer, virtual system or miscellaneous equipment with display at this algorithm provided.Various general-purpose system also can with use based on together with this teaching.According to description above, the structure constructed required by this type systematic is apparent.In addition, the present invention is not also for any certain programmed language.It should be understood that and various programming language can be utilized to realize content of the present invention described here, and the description done language-specific is above to disclose preferred forms of the present invention.
In instructions provided herein, describe a large amount of detail.But can understand, embodiments of the invention can be put into practice when not having these details.In some instances, be not shown specifically known method, structure and technology, so that not fuzzy understanding of this description.
Similarly, be to be understood that, in order to simplify the disclosure and to help to understand in each inventive aspect one or more, in the description above to exemplary embodiment of the present invention, each feature of the present invention is grouped together in single embodiment, figure or the description to it sometimes.But, the method for the disclosure should be construed to the following intention of reflection: namely the present invention for required protection requires feature more more than the feature clearly recorded in each claim.Or rather, as claims below reflect, all features of disclosed single embodiment before inventive aspect is to be less than.Therefore, the claims following embodiment are incorporated to this embodiment thus clearly, and wherein each claim itself is as independent embodiment of the present invention.
Those skilled in the art are appreciated that and adaptively can change the module in the equipment in embodiment and they are arranged in one or more equipment different from this embodiment.Module in embodiment or unit or assembly can be combined into a module or unit or assembly, and multiple submodule or subelement or sub-component can be put them in addition.Except at least some in such feature and/or process or unit be mutually repel except, any combination can be adopted to combine all processes of all features disclosed in this instructions (comprising adjoint claim, summary and accompanying drawing) and so disclosed any method or equipment or unit.Unless expressly stated otherwise, each feature disclosed in this instructions (comprising adjoint claim, summary and accompanying drawing) can by providing identical, alternative features that is equivalent or similar object replaces.
In addition, those skilled in the art can understand, although embodiments more described herein to comprise in other embodiment some included feature instead of further feature, the combination of the feature of different embodiment means and to be within scope of the present invention and to form different embodiments.Such as, in the following claims, the one of any of embodiment required for protection can use with arbitrary array mode.
All parts embodiment of the present invention with hardware implementing, or can realize with the software module run on one or more processor, or realizes with their combination.It will be understood by those of skill in the art that the some or all functions that microprocessor or digital signal processor (DSP) can be used in practice to realize according to the some or all parts in the equipment of the implantation information in the interception application program of the embodiment of the present invention.The present invention can also be embodied as part or all equipment for performing method as described herein or device program (such as, computer program and computer program).Realizing program of the present invention and can store on a computer-readable medium like this, or the form of one or more signal can be had.Such signal can be downloaded from internet website and obtain, or provides on carrier signal, or provides with any other form.
The present invention will be described instead of limit the invention to it should be noted above-described embodiment, and those skilled in the art can design alternative embodiment when not departing from the scope of claims.In the claims, any reference symbol between bracket should be configured to limitations on claims.Word " comprises " or " comprising " is not got rid of existence and do not arrange element in the claims or step.Word "a" or "an" before being positioned at element is not got rid of and be there is multiple such element.The present invention can by means of including the hardware of some different elements and realizing by means of the computing machine of suitably programming.In the unit claim listing some devices, several in these devices can be carry out imbody by same hardware branch.Word first, second and third-class use do not represent any order.Can be title by these word explanations.
The application can be applied to computer system/server, and it can operate with other universal or special computing system environment numerous or together with configuring.The example of the well-known computing system being suitable for using together with computer system/server, environment and/or configuration includes but not limited to: personal computer system, server computer system, thin client, thick client computer, hand-held or laptop devices, the system based on microprocessor, Set Top Box, programmable consumer electronics, NetPC Network PC, little type Ji calculate machine Xi Tong ﹑ large computer system and comprise the distributed cloud computing technology environment of above-mentioned any system, etc.
Computer system/server can describe under the general linguistic context of the computer system executable instruction (such as program module) performed by computer system.Usually, program module can comprise routine, program, target program, assembly, logic, data structure etc., and they perform specific task or realize specific abstract data type.Computer system/server can be implemented in distributed cloud computing environment, and in distributed cloud computing environment, task is performed by the remote processing devices by communication network links.In distributed cloud computing environment, program module can be positioned at and comprise on the Local or Remote computing system storage medium of memory device.
The present invention includes the actuating unit of A7, a kind of special instruction, be coupled between database and client, described device comprises:
First sending module, for sending special instruction, and the record relevant information corresponding with described special instruction, wherein, described relevant information comprises: send described special instruction use the mark of connection and/or the template instruction that described special instruction comprises;
Receiver module, for receiving the matching instruction of described special instruction;
Second sending module, for the described relevant information according to described first sending module record, adopts the send mode corresponding with described relevant information preset, sends to database to perform described matching instruction.
A8, device as described in claim A7, it is characterized in that, when described relevant information use to by the described special instruction of the transmission mark of connection, described second sending module specifically for, by described matching instruction by with transmission described special instruction use connection corresponding to the mark of connection to send to database to perform.
A9, device as described in claim A8, it is characterized in that, described device also comprises:
Keeping module, for sending after special instruction at described first sending module, is the connection used that keeps described first sending module to send described special instruction of described database and described client.
A10, device as described in claim A7, it is characterized in that, when described relevant information be described special instruction comprise template instruction time, described second sending module specifically for, according to described template instruction, and described matching instruction generates general instruction, database is sent to perform the general instruction generated.
A11, device as described in claim A10, it is characterized in that, described second sending module specifically for, judge whether comprise undetermined parameter in described template instruction, if so, be then described undetermined parameter assignment according to the parameter value comprised in described matching instruction, using the template instruction after assignment as the general instruction generated, otherwise, using described template instruction as the general instruction generated.
A12, as arbitrary in claim A7 ~ A11 as described in device, it is characterized in that, described instruction comprises: the instruction of Structured Query Language (SQL) SQL statement form;
When described relevant information use to by the described special instruction of the transmission mark of connection, described special instruction comprises BEGIN statement or PREPARE statement, when described special instruction is BEGIN statement, described matching instruction is the statement belonging to same db transaction with described BEGIN statement, when described special instruction is PREPARE statement, described matching instruction is EXECUTE statement or DEALLOCATE statement;
When described relevant information be described special instruction comprise template instruction time, described special instruction comprises PREPARE statement, and described matching instruction comprises EXECUTE statement.

Claims (10)

1. a manner of execution for special instruction, is applied to the middleware be coupled between database and client, and described method comprises:
Send special instruction, and the record relevant information corresponding with described special instruction, wherein, described relevant information comprises: send described special instruction use the mark of connection and/or the template instruction that described special instruction comprises;
Receive the matching instruction of described special instruction; And
According to the described relevant information of record, adopt the send mode corresponding with described relevant information preset, send to database to perform described matching instruction.
2. the method for claim 1, it is characterized in that, when described relevant information use to by the described special instruction of the transmission mark of connection, adopt the send mode corresponding with described relevant information preset, send to database to perform described matching instruction, specifically comprise:
By described matching instruction by with transmission described special instruction use connection corresponding to the mark of connection to send to database to perform.
3. method as claimed in claim 2, is characterized in that, after sending special instruction, described method also comprises:
For the connection that described database and described client keep the described special instruction of transmission to use.
4. the method for claim 1, it is characterized in that, when described relevant information be described special instruction comprise template instruction time, adopt preset the send mode corresponding with described relevant information, send to database to perform described matching instruction, specifically comprise:
According to described template instruction, and described matching instruction generates general instruction;
Database is sent to perform the general instruction generated.
5. method as claimed in claim 4, it is characterized in that, according to described template instruction, and described matching instruction generates general instruction, specifically comprises:
Judge whether comprise undetermined parameter in described template instruction;
If so, be then described undetermined parameter assignment according to the parameter value comprised in described matching instruction, using the template instruction after assignment as the general instruction generated;
Otherwise, using described template instruction as the general instruction generated.
6. the method as described in as arbitrary in Claims 1 to 5, it is characterized in that, described instruction comprises: the instruction of Structured Query Language (SQL) SQL statement form;
When described relevant information use to by the described special instruction of the transmission mark of connection, described special instruction comprises BEGIN statement or PREPARE statement, when described special instruction is BEGIN statement, described matching instruction is the statement belonging to same db transaction with described BEGIN statement, when described special instruction is PREPARE statement, described matching instruction is EXECUTE statement or DEALLOCATE statement;
When described relevant information be described special instruction comprise template instruction time, described special instruction comprises PREPARE statement, and described matching instruction comprises EXECUTE statement.
7. an actuating unit for special instruction, is coupled between database and client, and described device comprises:
First sending module, for sending special instruction, and the record relevant information corresponding with described special instruction, wherein, described relevant information comprises: send described special instruction use the mark of connection and/or the template instruction that described special instruction comprises;
Receiver module, for receiving the matching instruction of described special instruction;
Second sending module, for the described relevant information according to described first sending module record, adopts the send mode corresponding with described relevant information preset, sends to database to perform described matching instruction.
8. device as claimed in claim 7, it is characterized in that, when described relevant information use to by the described special instruction of the transmission mark of connection, described second sending module specifically for, by described matching instruction by with transmission described special instruction use connection corresponding to the mark of connection to send to database to perform.
9. device as claimed in claim 8, it is characterized in that, described device also comprises:
Keeping module, for sending after special instruction at described first sending module, is the connection used that keeps described first sending module to send described special instruction of described database and described client.
10. device as claimed in claim 7, it is characterized in that, when described relevant information be described special instruction comprise template instruction time, described second sending module specifically for, according to described template instruction, and described matching instruction generates general instruction, database is sent to perform the general instruction generated.
CN201410768908.7A 2014-12-12 2014-12-12 A kind of execution method and device of special instruction Active 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 true CN104636131A (en) 2015-05-20
CN104636131B CN104636131B (en) 2018-07-27

Family

ID=53214932

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201410768908.7A Active 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)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2016091068A1 (en) * 2014-12-12 2016-06-16 北京奇虎科技有限公司 Method and device for executing special instruction
CN107122633A (en) * 2016-02-24 2017-09-01 阿里巴巴集团控股有限公司 The instruction executing method and device of application program
CN112241418A (en) * 2019-07-17 2021-01-19 中兴通讯股份有限公司 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

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
沈钧毅: "《数据库系统原理》", 28 February 2014, 西安交通大学出版社 *

Cited By (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2016091068A1 (en) * 2014-12-12 2016-06-16 北京奇虎科技有限公司 Method and device for executing special instruction
CN107122633A (en) * 2016-02-24 2017-09-01 阿里巴巴集团控股有限公司 The instruction executing method and device of application program
CN107122633B (en) * 2016-02-24 2020-05-12 阿里巴巴集团控股有限公司 Instruction execution method and device of application program
CN112241418A (en) * 2019-07-17 2021-01-19 中兴通讯股份有限公司 Distributed database preprocessing method, agent layer, system and storage medium
WO2021008475A1 (en) * 2019-07-17 2021-01-21 中兴通讯股份有限公司 Distributed database preprocessing method, agent layer, system and storage medium
JP2022540128A (en) * 2019-07-17 2022-09-14 中興通訊股▲ふん▼有限公司 Distributed database preprocessing method and proxy layer, system, storage medium
US11847116B2 (en) 2019-07-17 2023-12-19 Xi'an Zhongxing New Software Co., Ltd. Distributed database preprocessing method, agent layer, system and storage medium

Also Published As

Publication number Publication date
WO2016091068A1 (en) 2016-06-16
CN104636131B (en) 2018-07-27

Similar Documents

Publication Publication Date Title
CN108664650B (en) Transaction processing method, device, equipment and storage medium of block chain network
CN104090889B (en) Data processing method and system
US9921569B2 (en) Field device commissioning system and method
JP2020531976A (en) A device that provides a set of cryptographically protected, filtered, and sorted transaction datasets for blockchain links.
CN105630488A (en) Docker container technology-based continuous integration realizing method
US10462261B2 (en) System and method for configuring a data access system
US10083059B1 (en) Method and system of hydrating of virtual machines
CN103370111A (en) Method and device for sending cloud server address
US10963888B2 (en) Payment complaint method, device, server and readable storage medium
CN106506715A (en) Domain name analytic method and device
CN107911249A (en) Order line sending method, device and the equipment of a kind of network equipment
CN110399169A (en) Amending method, device, equipment and the readable storage medium storing program for executing of BIOS option
CN103973682A (en) Method and device for having access to webpage
CN109905293A (en) A kind of terminal device recognition methods, system and storage medium
CN108932238A (en) A kind of cross-domain communication method and device
CN104636131A (en) Special instruction execution method and device
CN104951481A (en) Method and device for managing database connection
US20220164236A1 (en) System and method for adaptive release of application program in different environments
US20190171989A1 (en) Dynamic Workflow Control Based on Database Logic
US10338891B2 (en) Migration between model elements of different types in a modeling environment
CN104574188B (en) A kind of transaction service system and transaction processing method
CN100458800C (en) Automatic construction system and method for electronic circuit design
US20180196653A1 (en) Methods for adaptive placement of applications and devices thereof
CN107273328B (en) Interface management method and system
CN104391662A (en) Data reading and writing method and device

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

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.

TR01 Transfer of patent right