Embodiment
To make the purpose, technical scheme and advantage of the application clearer, below in conjunction with the application specific embodiment and
Technical scheme is clearly and completely described corresponding accompanying drawing.Obviously, described embodiment is only the application one
Section Example, rather than whole embodiments.Based on the embodiment in the application, those of ordinary skill in the art are not doing
Go out the every other embodiment obtained under the premise of creative work, belong to the scope of the application protection.
The data handling procedure provided in the embodiment of the present application is, it is necessary to which the first database used application program is replaced
When being changed to the second database, the business produced when first database is performed into service request within the latter time of pre- timing point
Process of the data " migration " into second database.Wherein, first database is the legacy data that the application program is used
Storehouse, second database is the replacement data storehouse for replacing the legacy data storehouse.
Generally, a period of time is right after the time point that the predetermined point of time can determine for staff, the predetermined point of time
The duration answered can also be determined by staff, i.e. being somebody's turn to do the end time of " migration " process can also be determined by staff.Also,
Because the data handling procedure of the duration and the application of the predetermined point of time and a period of time is not related, so the application
To this and it is not specifically limited.That is, data handling procedure described herein be after the predetermined point of time until
At the end of the duration of a period of time, the application performs data processing method during service request, is not related to the data processing
When method starts and when terminates.
Below in conjunction with accompanying drawing, the technical scheme that each embodiment of the application is provided is described in detail.
The data handling procedure that Fig. 1 provides for the embodiment of the present application, specifically includes following steps:
S101:Receive the service request to relevant database.
In the prior art, a business can be received business correspondence during execution, generally by application server
Service request, and the operation of subsequent step is determined according to the service request by the application server.
Similarly, in the embodiment of the present application, also service request can be received by application server, wherein, due to the application couple
What is answered is the process how data in database are carried out with data processing, so the service request can also be for relationship type number
According to the service request in storehouse.Again because the data handling procedure is to the data " migration " in first database to second data
Process in storehouse, so the application server can be to should the first database and second database, also, first data
Storehouse is the legacy data storehouse that the application server is used, and second database is that the application server is estimated in " migration " process
After end, what is used replaces the replacement data storehouse of first database, and first database and second database can be
Relevant database, can be as shown in Figure 2.
The structure of application server, first database and second database that Fig. 2 provides for the embodiment of the present application
Relation schematic diagram.It can be seen that, the application server is corresponding with first database and second database.
Wherein, the application server can be a single equipment or the system being made up of multiple devices
(that is, distributed application server), first database may each be a single equipment with second database, can also
The system (that is, distributed data base) being made up of multiple devices, the application is not limited this.
Further, since what application program generally performed is language (e.g., java language) in face of object, so the application clothes
The service request that receives of business device be generally also by this in face of object language generation, if but the service request be related to
The increase of data in database corresponding to the application server, inquiry, change, delete (Create, Retrieve, Update,
Delete, CRUD) operation, then because the language operated to relevant database is SQL
(Structured Query Language, SQL), it is not consistent in face of the language of object with this, so in the embodiment of the present application
In, the application server can also be closed when receiving the service request of this pair of relevant database by the object being pre-configured with
System's mapping (Object Relation Mapping, ORM) framework, the service request is converted to can be to relevant database
The SQL statement operated, subsequently to be operated to the relevant database, wherein, but the application server ORM frames
Frame, is operated using data Layer middleware to the relevant database, and the ORM frameworks can be specifically ibatis.
Then Fig. 2 can continue to be refined as Fig. 3.Application server that Fig. 3 provides for the embodiment of the present application, first database
And the detailed construction relation schematic diagram of second database.It can be seen that, the application server generates SQL statement by ORM frameworks,
Using data Layer middleware-operation this first and second database.
Also, because the application server is to that should have first database and second database, also, first He
Second wide area information server species and Database size are likely to difference, so can be advance in the application server
The first transformation rule for the service request to be converted to the SQL statement that can be operated to first database is configured with,
And the service request is converted to the second transformation rule of the SQL statement that can be operated to second database, wherein, by
SQLMAP is also generally referred to as in the transformation rule, so first transformation rule is referred to as into first in subsequent descriptions
SQLMAP, is referred to as the 2nd SQLMAP by second transformation rule.
For example, it is assumed that application server A is to that should have the first database B and the second database C, wherein, first data
Storehouse B and second database C is relevant database, and the corresponding application programs of application server A use Java languages
Speech, it is further assumed that first database B is mysql, second database C is oracle, then also pre- in application server A
The first SQLMAP that Java language is converted to corresponding first SQL statement of mysql databases is first configured with, by Java language
Be converted to the 2nd SQLMAP of corresponding second SQL statement of oracle database, the first SQLMAP and the 2nd SQLMAP
Configure in the ORM frameworks of the application server, and application server A is received and the business of relevant database is asked
Seek D.
S102:According to the service request and the first transformation rule being pre-configured with, the service request correspondence is generated
The first SQL statement, and according to the service request and the second transformation rule being pre-configured with, generate the second SQL statement.
In the embodiment of the present application, after the application server receives the service request to relevant database, just may be used
An idle thread is determined, and the service request is performed by the thread, wherein, the thread first can change the service request
To perform the first SQL statement of respective operations to first database, it is reconverted into and respective operations is performed to second database
The second SQL statement.
Specifically, the application server can first determine an idle thread, and the thread is set to pass through the application server
The first SQLMAP being pre-configured with ORM frameworks, first SQL statement is generated according to the service request, and due to the ORM
The 2nd SQLMAP is also provided with framework in advance, so the thread can also be generated as the 2nd SQL languages according to the service request
Sentence, so that the application server can be performed respectively to first database by first SQL statement and second SQL statement
And second data perform corresponding operation.
Further, since in the embodiment of the present application, second database is as replacement data storehouse, and the data volume of storage is relative
It is less in the data volume of first database purchase, it can support that the probability that the application server is normally run is relatively low, if so
Any service request to the relevant database respectively generates first SQL statement and second SQL statement, then may
Second SQL statement is caused to perform the probability increase of failure.Also, in data handling procedure described herein, it is only necessary to make
The change of data is equally present in the second server in first database caused by the service request, i.e. ensured
After the default time point, the value of the data in second database occurs after change with data in first database
The value of data is consistent, so in the embodiment of the present application, to the data handling procedure can only for the increasing to data,
The operation delete, changed, without inquiry operation is carried out data handling procedure described herein (inquiry operation will not change this
The value of data storage in one database).
Because staff can determine which kind of service request of the application program is needed in first database
The operation that data are increased, deleted, changed, so in this application, can also be previously stored with the application server by working
The service identification list that personnel determine, wherein, the business represents each service identification in list, is to need to first data
The service identification of the service request for the operation that storehouse is increased, deleted, changed, then the application server can also pass through the service request pair
The service identification answered, it is determined whether generate second SQL statement.
Specifically, the service request pair can be carried in the service request that the application server is received in step S101
The service identification answered, then, first, can be by the industry when the application server will call idle thread according to the service request
Business mark is write in the thread variable of the thread.Secondly, the thread according to the first SQLMAP generate first SQL statement it
Afterwards, the data Layer middleware can be used to perform first SQL statement to operate first database, then in the data Layer
Between part the service identification can be determined by the thread variable of the thread.Afterwards, the data Layer middleware can be according to prestoring
The service identification list, judge whether the service identification identical with any service identification in the service identification list, if phase
Together, it is determined that need to generate second SQL statement, then the thread can also generate second SQL statement by the 2nd SQLMAP,
Subsequent execution this first and second SQL statement, if it is different, then determine to generate second SQL statement, the thread can be after
It is continuous to perform subsequent operation (corresponding operation e.g., is performed to first database according to first SQL statement).
Continue to use the example above, it is assumed that application server A determines that idle thread x performs the service request, then the application
Server can write the service identification y of the service request in thread x thread variable, then thread x passes through the ORM frameworks
In the first SQLMAP that is pre-configured with generate after the first SQL statement, perform first SQL statement using the data Layer middleware
When, service identification y can be determined by thread x thread variable, it is further assumed that prestored in application server A
Service identification y is included in service identification list, then the data Layer middleware, can be further true when performing first SQL statement
Surely need to generate the second SQL statement, then thread x can also generate the second SQL statement by the 2nd SQLMAP, then thread x
The data Layer middleware can be used to perform first SQL statement and second SQL statement.
S103:Corresponding operation is performed to the first relevant database by first SQL statement, and passes through second
SQL statement performs corresponding operation to the second relevant database.
In the embodiment of the present application, when generate this first and after second SQL statement, the application server just can lead to
The thread is crossed using the data Layer middleware, corresponding operation is performed to first database and second database.
Also, because first database and second database are two independent databases, thus can for this
One SQL statement and second SQL statement set up corresponding affairs respectively, further, in order to ensure in second database
Data can be consistent with the data after the change in first database, so in this application can only when this first
First SQL statement and second SQL statement is just submitted to distinguish corresponding affairs when being performed both by successfully with the second SQL statement.
Specifically, the thread use the data Layer middleware, first, foundation performed in first database this first
First affairs of SQL statement, secondly, set up the second affairs that second SQL statement is performed in second database, afterwards,
The corresponding operation of first SQL statement is performed in first database according to first SQL statement, then, according to this second
SQL statement performs the corresponding operation of second SQL statement in second database, also, when first SQL statement and is somebody's turn to do
Second SQL statement, when respectively running succeeded, submits first affairs and second affairs, and if, first affairs are set up
Failure or second affairs set up failure or first SQL statement performs failure or second SQL statement performs failure,
Then the thread returns to error message (mistake of also referred to as dishing out), and performs rolling back action, makes first database and second number
According to the data recovery in storehouse to perform step S103 before state, as shown in Figure 4.
Fig. 4 for the embodiment of the present application provide performed respectively in first database and second database this first
The schematic diagram of SQL statement and the second SQL statement process.
It can be seen that, corresponding operation is performed to the first database by first SQL statement and passes through the second SQL statement pair
During second database performs corresponding operation, as long as mistake or failure occurs in either step, the thread can be thrown
Make mistake and perform rolling back action, to should service request when first affairs and second affairs are submitted successfully after
Operation execution terminates.
It can ensure that first database is with being somebody's turn to do for the corresponding operation of the service request by step as shown in Figure 4
The change of data is identical in second database, is not in that one of database runs succeeded and another performs mistake
Lose, cause the inconsistent situation of data to occur.
It should be noted that as it was previously stated, it can also be by Duo Tai that the application server, which can be a single equipment,
The system of equipment composition, thus the embodiment of the present application as shown in Figure 1 the executive agent of each step of method is provided can be with
It is same equipment, or, this method also can be used as executive agent by distinct device.Such as, step S101 and step S102 is held
Row main body can be equipment 1, and step S103 executive agent can be equipment 2;Again such as, step S101 executive agent can be with
For equipment 1, step S102 and step S103 executive agent can be equipment 2;Etc..
By data processing method as shown in Figure 1, can be received according to the application service to relevant database
Service request, generation respectively to the operation of the execution of first database and second database this first and second
SQL statement so that the service request can perform corresponding operation by second SQL statement in second database, make
The data in second database are obtained, are no longer obtained merely by the data handling procedure of " asynchronous pair is write " of database aspect
Arrive, but obtained by the service request of application, also, in this application, only when first SQL statement and this
When two SQL statements are performed both by successfully, corresponding first affairs and second affairs can just be submitted respectively, make first data
Storehouse and second database produce actual data variation, so the data handling procedure provided by the application, not only may be used
Contacting for reality is produced with application with the operation to second database for being, and first and second database can be ensured
The uniformity of middle data (specially the change of data is consistent after the preset time point) so that second database is at this section
Between duration at the end of, can directly support the operation of the application, it is to avoid follow-up needs enter to data in second database
The process of row checking, reduces the cost of database replacement.
In addition, in this application, due to before second SQL statement generation, having been generated in the application server
First SQL statement, so the 2nd SQLMAP is alternatively, is carried out according to first SQL statement generation to second database
Operation the second SQL statement rule, then the thread it is determined that need generate second SQL statement when, can according to this first
SQL statement and the 2nd SQLMAP generate second SQL statement.
Further, due to that for the application program, can need not be concerned about whether the application server will be according to the industry
Business request, carries out corresponding operation, so the content of the service request respectively to first database and second database
Can be only for first database, and the application server can be realized according to the application request subsequent step S102 with
And S103 operation.
In addition, being to be said using the application server as executive agent during the described above of the embodiment of the present application
Bright, i.e. data Layer middleware is contained in the application program run in the application server, still, the data Layer middleware
Also can exist as a single program or system, so in the embodiment of the present application, also can be by the data Layer middleware
Perform the part and step S103 in above-mentioned steps S102.
Specifically, when the data Layer middleware is as a single program, face can be also run in the application server
To the application program (being, to show difference, to be subsequently referred to as top layer application) of user, the top layer is applied to receive the operation of user, really
Determine service request, and first SQL statement is generated according to the first SQLMAP being pre-configured with, and first SQL statement is sent
Into the data Layer middleware so that the data Layer middleware perform subsequent operation.
In the embodiment of the present application, the application server is according to the service identification list and the service request prestored
Service identification of middle carrying, it is determined that needing to generate second SQL statement for operating second relevant database, tool
Body can be:
The top layer is applied after the service request is received, and first SQL statement can be generated according to the first SQLMAP, and
The corresponding service identification write-in of the service request is performed in the thread of first SQL statement, and sent to the data Layer
Part.Then the data Layer middleware can determine the service identification write in the thread variable, and pass through by running the thread
The service identification list prestored, it is determined whether to generate the second SQL statement, if desired, then with according to being somebody's turn to do that this is pre-configured with
2nd SQLMAP, generates second SQL statement.Also, step S103 whole mistakes can be subsequently performed by the data Layer middleware
Journey, process that specifically can be as shown in Figure 4 is consistent.
Further, applied and the data Layer middleware due to the top layer can be divided into the application server, and on
State two programs can make it is separate, so this be pre-configured with first and the 2nd SQLMAP can be the top layer application
And the data Layer middleware is addressable.
Further, due to the top layer is applied to the data Layer middleware can be independent mutually, then top layer application can be with
The data Layer middleware is carried out by application programming interface (Application Programming Interface, API)
Data interaction, then, can be by staff in advance in the table when the top layer with the data Layer middleware using connecting for the first time
The statement file that configures in layer application, states that the top layer is applied to should first and second data to the data Layer middleware
In storehouse, wherein the statement file comprising this first and second database distinguish corresponding database address, database configuration
Deng database information.
Certainly, the top layer is applied can also be located in same application program with the data Layer middleware, and the application is to this
And be not specially limited, when the data Layer middleware is an independent program, then the data Layer middleware may be alternatively located at independence
One or more equipment in, and the data Layer middleware can also be connected with the application of multiple top layers, and to multiple databases
Operated respectively.Also, because the application is related to " migration " process of data in database, thus only to exist this first with
And second the situation of database be illustrated, but method described herein do not limit it is only corresponding with the application server
In two databases, the application server can also correspond to multiple databases, as long as being provided with correspondence in the application server in advance
SQLMAP.
Further, since the data Layer middleware can directly invoke first and the 2nd SQLMAP, institute being pre-configured with
With in this application, also can by service request of the data Layer middleware to relevant database, and generate this first and
Two SQL statements, finally perform first and second SQL statement, it is necessary to explanation, the industry that the data Layer middleware is received
Business request can be different from foregoing service request, and (for show difference, subsequently referred to as request of data) can be specifically by the table
Layer application is sent to the service request of the data Layer middleware after processing, specifically, top layer application can be according to connecing
The service request received, according to service logic, it is determined that needing the operation performed to data, and the operation is sent out as request of data
The data Layer middleware is delivered to, to cause the data Layer middleware to perform subsequent operation.
, can be with it should be noted that the language that the application program is used is in addition to Java language described in Fig. 1
C language, other language of C Plus Plus etc., the ORM frameworks in addition to the ibatis, can also be Entity EJB,
The type of Hibernate, TopLink, OJB etc., first database and second database can be Oracle, DB2,
Microsoft SQL Server etc., the ORM that language that the application is used for the application program, the application server are used
The type of framework and first and second database is simultaneously not specifically limited.
Based on the data handling procedure shown in Fig. 1, the embodiment of the present application, which is also corresponded to, provides a kind of data processing equipment, such as schemes
Shown in 5.
Fig. 5 is that the embodiment of the present application provides a kind of structural representation of data processing equipment, including:
Receiving module 201, receives the service request to relevant database;
Generation module 202, according to the service request and the first transformation rule being pre-configured with, generating the business please
Corresponding first SQL statement is sought, and according to the service request and the second transformation rule being pre-configured with, generation second
SQL statement;
Performing module 203, corresponding operation is performed to the first relevant database by first SQL statement, and
Corresponding operation is performed to the second relevant database by the second SQL statement.
Service identification is carried in the service request;
The generation module 202, according to the institute carried in the service identification list and the service request prestored
Service identification is stated, it is determined that needing to generate second SQL statement for operating second relevant database.
The receiving module 201, the service identification is write the thread variable for the thread for performing first SQL statement
In;
The generation module 202, when performing first SQL statement by the thread, according to the thread variable
The service identification is determined, according to the service identification list and the service identification prestored, it is determined that needing to generate to institute
State second SQL statement that the second relevant database is operated.
The performing module 203, foundation performs the first of first SQL statement in first relevant database
Affairs, set up the second affairs that second SQL statement is performed in second relevant database, according to described first
SQL statement performs corresponding operation in first relevant database, is closed according to second SQL statement described second
It is to perform corresponding operation in type database, when first SQL statement and second SQL statement are performed both by successfully,
First affairs and second affairs are submitted, when first SQL statement and/or second SQL statement perform mistake
When losing, error message is returned to, and perform rolling back action.
First relevant database is legacy data storehouse, and second relevant database is replacement data storehouse, institute
Stating corresponding operation includes at least one of increase, deletion, change.
Specifically, above-mentioned data processing equipment as shown in Figure 4 can be located in application server, the application server can
With the system for being an equipment or being made up of multiple devices.
It should be understood by those skilled in the art that, embodiments of the invention can be provided as method, system or computer program
Product.Therefore, the present invention can be using the reality in terms of complete hardware embodiment, complete software embodiment or combination software and hardware
Apply the form of example.Moreover, the present invention can be used in one or more computers for wherein including computer usable program code
The computer program production that usable storage medium is implemented on (including but is not limited to magnetic disk storage, CD-ROM, optical memory etc.)
The form of product.
The present invention is the flow with reference to method according to embodiments of the present invention, equipment (system) and computer program product
Figure and/or block diagram are described.It should be understood that can be by every first-class in computer program instructions implementation process figure and/or block diagram
Journey and/or the flow in square frame and flow chart and/or block diagram and/or the combination of square frame.These computer programs can be provided
The processor of all-purpose computer, special-purpose computer, Embedded Processor or other programmable data processing devices is instructed to produce
A raw machine so that produced by the instruction of computer or the computing device of other programmable data processing devices for real
The device for the function of being specified in present one flow of flow chart or one square frame of multiple flows and/or block diagram or multiple square frames.
These computer program instructions, which may be alternatively stored in, can guide computer or other programmable data processing devices with spy
Determine in the computer-readable memory that mode works so that the instruction being stored in the computer-readable memory, which is produced, to be included referring to
Make the manufacture of device, the command device realize in one flow of flow chart or multiple flows and/or one square frame of block diagram or
The function of being specified in multiple square frames.
These computer program instructions can be also loaded into computer or other programmable data processing devices so that in meter
Series of operation steps is performed on calculation machine or other programmable devices to produce computer implemented processing, thus in computer or
The instruction performed on other programmable devices is provided for realizing in one flow of flow chart or multiple flows and/or block diagram one
The step of function of being specified in individual square frame or multiple square frames.
In a typical configuration, computing device includes one or more processors (CPU), input/output interface, net
Network interface and internal memory.
Internal memory potentially includes the volatile memory in computer-readable medium, random access memory (RAM) and/or
The forms such as Nonvolatile memory, such as read-only storage (ROM) or flash memory (flash RAM).Internal memory is computer-readable medium
Example.
Computer-readable medium includes permanent and non-permanent, removable and non-removable media can be by any method
Or technology come realize information store.Information can be computer-readable instruction, data structure, the module of program or other data.
The example of the storage medium of computer includes, but are not limited to phase transition internal memory (PRAM), static RAM (SRAM), moved
State random access memory (DRAM), other kinds of random access memory (RAM), read-only storage (ROM), electric erasable
Programmable read only memory (EEPROM), fast flash memory bank or other memory techniques, read-only optical disc read-only storage (CD-ROM),
Digital versatile disc (DVD) or other optical storages, magnetic cassette tape, the storage of tape magnetic rigid disk or other magnetic storage apparatus
Or any other non-transmission medium, the information that can be accessed by a computing device available for storage.Define, calculate according to herein
Machine computer-readable recording medium does not include temporary computer readable media (transitory media), such as data-signal and carrier wave of modulation.
It should also be noted that, term " comprising ", "comprising" or its any other variant are intended to nonexcludability
Comprising so that process, method, commodity or equipment including a series of key elements are not only including those key elements, but also wrap
Include other key elements being not expressly set out, or also include for this process, method, commodity or equipment intrinsic want
Element.In the absence of more restrictions, the key element limited by sentence "including a ...", it is not excluded that wanted including described
Also there is other identical element in process, method, commodity or the equipment of element.
It will be understood by those skilled in the art that embodiments herein can be provided as method, system or computer program product.
Therefore, the application can be using the embodiment in terms of complete hardware embodiment, complete software embodiment or combination software and hardware
Form.Deposited moreover, the application can use to can use in one or more computers for wherein including computer usable program code
The shape for the computer program product that storage media is implemented on (including but is not limited to magnetic disk storage, CD-ROM, optical memory etc.)
Formula.
Embodiments herein is the foregoing is only, the application is not limited to.For those skilled in the art
For, the application can have various modifications and variations.It is all any modifications made within spirit herein and principle, equivalent
Replace, improve etc., it should be included within the scope of claims hereof.