CN109992617A - Support the data access method and system of a variety of programming languages and multiple data sources - Google Patents

Support the data access method and system of a variety of programming languages and multiple data sources Download PDF

Info

Publication number
CN109992617A
CN109992617A CN201910215253.3A CN201910215253A CN109992617A CN 109992617 A CN109992617 A CN 109992617A CN 201910215253 A CN201910215253 A CN 201910215253A CN 109992617 A CN109992617 A CN 109992617A
Authority
CN
China
Prior art keywords
data
connection
access
request
module
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
CN201910215253.3A
Other languages
Chinese (zh)
Other versions
CN109992617B (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.)
State Grid Corp of China SGCC
State Grid Jiangsu Electric Power Co Ltd
Nari Technology Co Ltd
Original Assignee
State Grid Corp of China SGCC
State Grid Jiangsu Electric Power Co Ltd
Nari Technology 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 State Grid Corp of China SGCC, State Grid Jiangsu Electric Power Co Ltd, Nari Technology Co Ltd filed Critical State Grid Corp of China SGCC
Priority to CN201910215253.3A priority Critical patent/CN109992617B/en
Publication of CN109992617A publication Critical patent/CN109992617A/en
Application granted granted Critical
Publication of CN109992617B publication Critical patent/CN109992617B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y04INFORMATION OR COMMUNICATION TECHNOLOGIES HAVING AN IMPACT ON OTHER TECHNOLOGY AREAS
    • Y04SSYSTEMS INTEGRATING TECHNOLOGIES RELATED TO POWER NETWORK OPERATION, COMMUNICATION OR INFORMATION TECHNOLOGIES FOR IMPROVING THE ELECTRICAL POWER GENERATION, TRANSMISSION, DISTRIBUTION, MANAGEMENT OR USAGE, i.e. SMART GRIDS
    • Y04S10/00Systems supporting electrical power generation, transmission or distribution
    • Y04S10/50Systems or methods supporting the power network operation or management, involving a certain degree of interaction with the load-side end user applications

Landscapes

  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
  • Computer And Data Communications (AREA)

Abstract

The invention discloses a kind of data access methods and system for supporting a variety of programming languages and multiple data sources.The present invention is based on preset rules to convert access request for the required parameter of input, solves the problems, such as across programming language;It is accessed request analysis based on coding, solves multi-platform compatibility issue;The presence of multi-source connection pool solves the problems, such as that multi-data source connects handle complex management, realizes multi-data source access.

Description

Support the data access method and system of a variety of programming languages and multiple data sources
Technical field
The present invention relates to a kind of data access methods and system for supporting a variety of programming languages and multiple data sources, belong to electricity Force system automates electric network model administrative skill field.
Background technique
As electric network data storage is increasingly numerous and jumbled, system business data call mode is more and more diversified, standardization and letter The demand for changing each service data visitation mode is also increasingly prominent.Therefore need it is a kind of being capable of unified number across language, across data source According to access mode.
Summary of the invention
The present invention provides a kind of data access methods and system for supporting a variety of programming languages and multiple data sources, solve Available data access there are the problem of.
In order to solve the above-mentioned technical problem, the technical scheme adopted by the invention is that:
Data access method, including,
Access request is converted by the required parameter of input according to preset rules, and access request is sent to data service End;It wherein, include all required parameters in access request, required parameter includes data source connector, access sentence, returns to lattice Formula and coding;
Receive the data feedback at data service end.
When sending access request, if data service end is available, directly transmit, it, will be defeated if data service end is unavailable The required parameter write-in buffer area entered preferentially converts access request simultaneously for buffer-request parameter after data service end is available It sends.
Coding is located at the first byte of access request, and the subsequent byte of access request is the content after being encoded.
Data access method, including,
Receive the access request that request end is sent;It wherein, include all required parameters, required parameter packet in access request It includes data source connector, access sentence, return to format and coding;
Coding in read access request parses access request according to coding;
Data source is connected, data source is accessed according to access sentence, and according to returning to format to request end returned data.
Connect data source, access data source obtain data detailed process be,
S1 judges that the corresponding connection pool of data source whether there is in access request, and if it exists, go to S3, turn if it does not exist To S2;
S2 creates the connection pool of the data source and creates connection, goes to S6;
S3 judges in connection pool with the presence or absence of idle connection, and if it exists, then obtain connection, go to S6;If it does not exist, then Go to S4;
S4 judges to enliven whether connection number reaches the upper limit in connection pool, if it is not, the then new connection of creation, goes to S6;If It is then to go to S5;
S5 judges whether there is connection time-out, if so, then removing overtime connection, creates new connection, goes to S6;If no, It waits until there is connection available, goes to S6;
S6 accesses data source according to access sentence, and according to returning to format to request end returned data.
Coding is located at the first byte of access request, the first byte of read access request, according to code parsing access request Subsequent byte.
Data access system, including the request end being in communication with each other and data server-side;
Request end includes conversion module and data reception module;
Conversion module: access request is converted by the required parameter of input according to preset rules, and access request is sent Give data service end;It wherein, include all required parameters in access request, required parameter includes data source connector, access Sentence returns to format and coding;
Data reception module: the data feedback at data service end is received;
Data service end includes access request receiving module, parsing module and access modules;
Access request receiving module: the access request that request end is sent is received;
Parsing module: the coding in read access request parses access request according to coding;
Access modules: connection data source accesses data source according to access sentence, and returns according to format is returned to request end Data.
Request end further includes cache module,
Cache module: when sending access request, if data service end is unavailable, buffering is written into the required parameter of input Area preferentially converts access request for buffer-request parameter and sends after data service end is available.
Access modules include connection pool there are judgment module, connection pool creation module, idle connection judgment module, actively connect It connects several upper limit judgment modules, overtime connection judgment module, obtain data module;
There are judgment modules for connection pool: judging that the connection pool of data source in access request whether there is, and if it exists, go to sky Not busy connection judgment module, goes to connection pool creation module if it does not exist;
Connection pool creation module: creating the connection pool of the data source and creates connection, goes to acquisition data module;
Idle connection judgment module: judge in connection pool with the presence or absence of idle connection, and if it exists, then obtain connection, go to Obtain data module;If it does not exist, then it goes to and enlivens connection number upper limit judgment module;
It enlivens connection number upper limit judgment module: judging to enliven whether connection number reaches the upper limit in connection pool, if it is not, then creating New connection is built, acquisition data module is gone to;If so, going to overtime connection judgment module;
Overtime connection judgment module: judging whether there is connection time-out, if so, then removing overtime connection, creates new connection, turns To acquisition data module;If no, waiting until there is connection available, acquisition data module is gone to;
It obtains data module: data source is accessed according to access sentence, and according to returning to format to request end returned data.
Coding is located at the first byte of access request, and the subsequent byte of access request is the content after being encoded, parsing module The first byte of read access request, according to the subsequent byte of code parsing access request.
It is asked advantageous effects of the invention: converting access for the required parameter of input the present invention is based on preset rules It asks, solves the problems, such as across programming language;It is accessed request analysis based on coding, solves multi-platform compatibility issue;It is more The presence of source connection pool solves the problems, such as that multi-data source connects handle complex management, realizes multi-data source access.
Detailed description of the invention
Fig. 1 is the flow chart of request end;
Fig. 2 is the flow chart for converting access request;
Fig. 3 is the flow chart at data service end;
Fig. 4 is the flow chart of parsing;
Fig. 5 is the flow chart of data assembling;
Fig. 6 is flow chart of the invention.
Specific embodiment
The invention will be further described below in conjunction with the accompanying drawings.Following embodiment is only used for clearly illustrating the present invention Technical solution, and not intended to limit the protection scope of the present invention.
Support the data access method of a variety of programming languages and multiple data sources, in this method, the interaction of message mainly has Both ends, i.e. request end and data server-side, wherein request end is mainly used for issuing access request and receives feedback data, data clothes Business end is mainly used for receiving access request, access data source and feedback data.
The main flow of request end is as shown in Figure 1, specific as follows:
A1 access request) is converted by the required parameter of input according to preset rules, and access request is passed through into Transmission Control Protocol It is sent to data service end.
When sending access request, if data service end is available, directly transmit, it, will be defeated if data service end is unavailable The required parameter write-in buffer area entered preferentially converts access request simultaneously for buffer-request parameter after data service end is available It sends.
Since access mode of the different development language to different data sources is different, it is contemplated that the elements such as compatible unification need Access request is carried out it is unified, as shown in Figure 2, it is believed that the required parameter being manually entered is converted unified format by setting rule Access request, include all required parameters in access request, required parameter includes data source connector, access sentence, returns Format and coding are returned, wherein it is encoded to the coding mode of entire access request, such as UTF-8 coding, GBK coding, for the ease of Subsequent parsing, coding are located at the first byte of access request, and the subsequent byte of access request is the content after being encoded.
It is exemplified below, access request uses the format of character string, such as: data source connector " mysql: // 10.25.222.31/myDB? user=soft&password=xxxx ", access sentence (query statement) are " select id From Persons where name=' xxx ' ", returning to format is to return by row, is encoded to UTF-8 coding, ultimately generates word Symbol string pattern are as follows: 0x01 " source ": " rdb ", " connect ": " mysql: // 10.25.222.31/myDB? user= Soft&password=xxxx ", " sql ": " select id from Persons where name=' xxx ' ", "dataformat":"xquery"};Wherein 0x01 indicates UTF-8 coding.
A2 the data feedback at data service end) is received.
The main flow at data service end is as shown in figure 3, specific as follows:
B1 the access request that request end is sent) is received.
B2) the coding in read access request parses access request according to coding.
As shown in figure 4, the first byte of read access request, identification coding, if can not identify, report an error, return to request end It is illegal to return content, if identifying successfully, according to the subsequent byte of code parsing access request.
B3 data source) is connected, data source is accessed according to access sentence, and according to returning to format to request end returned data.
Detailed process is as follows by step B3:
S1 judges that the corresponding connection pool of data source whether there is in access request, and if it exists, go to S3, turn if it does not exist To S2;
Above-mentioned connection pool is the connection pool of multi-data source, and non-individual one data source, is mapped using keyword, every kind Keyword maps a kind of connection pool of data source, is similar to { " rdb ": " relationship library connection pool ", " rtdb ": " real-time database connection Pond ", " file ": " file source connection pool " }
S2 creates the connection pool of the data source and creates connection, goes to S6;
S3 judges in connection pool with the presence or absence of idle connection, and if it exists, then obtain connection, go to S6;If it does not exist, then Go to S4;
S4 judges to enliven whether connection number reaches the upper limit in connection pool, if it is not, the then new connection of creation, goes to S6;If It is then to go to S5;
S5 judges whether there is connection time-out, if so, then removing overtime connection, creates new connection, goes to S6;If no, It waits until there is connection available, goes to S6;
S6 accesses data source according to access sentence, and according to returning to format to request end returned data.
Since the data that access obtains are unordered, it is therefore desirable to be assembled according to format is returned, specifically such as Fig. 5 institute Show, illustrate: if dataformat (returning to format) is xquery (returning by row), then data are arranged by row, format are as follows: " query result":[{"table_id":1,"table_name_chn":"\u8868\u4fe1\u606f\u8868"},{" table_id":2,"table_name_chn":"\u57df\u4fe1\u606f\u8868"}]};As dataformat is Yquery, then data are arranged by column, format are as follows: { " query result ": [{ " table_id ": [1,2] }, { " table_ name_chn":["\u8868\u4fe1\u606f\u8868","\u57df\u4fe1\u606f\u8868"]}]}.Wherein " Table_id ", " table_name_chn " be inquiry column title, ' 1 ', ' 2 ' etc. be specific data content.
To sum up, as shown in fig. 6, the detailed process of data access method is as follows:
Step 1, request end converts access request for the required parameter of input according to preset rules, and access request is sent out Give data service end.
Step 2, data service end receives the access request that request end is sent.
Step 3, the coding in the read access request of data service end parses access request according to coding.
Step 4, data service end connects data source, accesses data source according to access sentence, and according to returning to format to asking Seek end returned data.
Step 5, request end receives the data feedback at data service end.
It is above-mentioned to convert access request for the required parameter of input based on preset rules, number is transmitted using computer network with standard network protocol According to so that request of data independent of certain programmed language, is solved the problems, such as across programming language, communication efficiency and communication solution The various problems such as coupling;It is accessed request analysis based on coding, supports a variety of coded formats, solve multi-platform compatibility and ask Topic;The presence of multi-source connection pool solves the problems, such as that multi-data source connects handle complex management, realizes multi-data source access.
The above-mentioned corresponding system of data access method, including the request end being in communication with each other and data server-side.
Request end includes conversion module and data reception module.
Conversion module: access request is converted by the required parameter of input according to preset rules, and access request is sent Give data service end;It wherein, include all required parameters in access request, required parameter includes data source connector, access Sentence returns to format and coding.
Data reception module: the data feedback at data service end is received.
Data service end includes access request receiving module, parsing module and access modules.
Access request receiving module: the access request that request end is sent is received.
Parsing module: the coding in read access request parses access request according to coding.
Coding is located at the first byte of access request, and the subsequent byte of access request is the content after being encoded, parsing module The first byte of read access request, according to the subsequent byte of code parsing access request.
Access modules: connection data source accesses data source according to access sentence, and returns according to format is returned to request end Data.
Access modules include connection pool there are judgment module, connection pool creation module, idle connection judgment module, actively connect It connects several upper limit judgment modules, overtime connection judgment module, obtain data module;
There are judgment modules for connection pool: judging that the corresponding connection pool of data source whether there is in access request, and if it exists, turns To idle connection judgment module, connection pool creation module is gone to if it does not exist;
Connection pool creation module: creating the connection pool of the data source and creates connection, goes to acquisition data module;
Idle connection judgment module: judge in connection pool with the presence or absence of idle connection, and if it exists, then obtain connection, go to Obtain data module;If it does not exist, then it goes to and enlivens connection number upper limit judgment module;
It enlivens connection number upper limit judgment module: judging to enliven whether connection number reaches the upper limit in connection pool, if it is not, then creating New connection is built, acquisition data module is gone to;If so, going to overtime connection judgment module;
Overtime connection judgment module: judging whether there is connection time-out, if so, then removing overtime connection, creates new connection, turns To acquisition data module;If no, waiting until there is connection available, acquisition data module is gone to;
It obtains data module: data source is accessed according to access sentence, and according to returning to format to request end returned data.
Cache module: when sending access request, if data service end is unavailable, buffering is written into the required parameter of input Area preferentially converts access request for buffer-request parameter and sends after data service end is available.
The above is only a preferred embodiment of the present invention, it is noted that for the ordinary skill people of the art For member, without departing from the technical principles of the invention, several improvement and deformations can also be made, these improvement and deformations Also it should be regarded as protection scope of the present invention.

Claims (10)

1. data access method, it is characterised in that: including,
Access request is converted by the required parameter of input according to preset rules, and access request is sent to data service end; It wherein, include all required parameters in access request, required parameter includes data source connector, access sentence, returns to format And coding;
Receive the data feedback at data service end.
2. data access method according to claim 1, it is characterised in that: when sending access request, if data service end It can use, then directly transmit, if data service end is unavailable, buffer area is written into the required parameter of input, data service end can With rear, access request preferentially is converted by buffer-request parameter and is sent.
3. data access method according to claim 1, it is characterised in that: coding is located at the first byte of access request, visits The subsequent byte for asking request is the content after being encoded.
4. data access method, it is characterised in that: including,
Receive the access request that request end is sent;It wherein, include all required parameters in access request, required parameter includes number According to source connector, access sentence, return to format and coding;
Coding in read access request parses access request according to coding;
Data source is connected, data source is accessed according to access sentence, and according to returning to format to request end returned data.
5. data access method according to claim 4, it is characterised in that: connection data source, access data source obtain number According to detailed process be,
S1 judges that the corresponding connection pool of data source whether there is in access request, and if it exists, go to S3, go to S2 if it does not exist;
S2 creates the connection pool of the data source and creates connection, goes to S6;
S3 judges in connection pool with the presence or absence of idle connection, and if it exists, then obtain connection, go to S6;If it does not exist, then it goes to S4;
S4 judges to enliven whether connection number reaches the upper limit in connection pool, if it is not, the then new connection of creation, goes to S6;If so, Go to S5;
S5 judges whether there is connection time-out, if so, then removing overtime connection, creates new connection, goes to S6;If no, waiting Until there is connection available, S6 is gone to;
S6 accesses data source according to access sentence, and according to returning to format to request end returned data.
6. data access method according to claim 4, it is characterised in that: coding is located at the first byte of access request, reads The first byte for taking access request, according to the subsequent byte of code parsing access request.
7. data access system, it is characterised in that: including the request end being in communication with each other and data server-side;
Request end includes conversion module and data reception module;
Conversion module: access request is converted by the required parameter of input according to preset rules, and access request is sent to number According to server-side;Wherein, in access request include all required parameters, required parameter include data source connector, access sentence, Return to format and coding;
Data reception module: the data feedback at data service end is received;
Data service end includes access request receiving module, parsing module and access modules;
Access request receiving module: the access request that request end is sent is received;
Parsing module: the coding in read access request parses access request according to coding;
Access modules: connection data source accesses data source according to access sentence, and returns to number to request end according to format is returned According to.
8. data access system according to claim 7, it is characterised in that: request end further includes cache module,
Cache module: when sending access request, if data service end is unavailable, being written buffer area for the required parameter of input, After data service end is available, access request preferentially is converted by buffer-request parameter and is sent.
9. data access system according to claim 7, it is characterised in that: access modules include that connection pool presence judges mould Block, idle connection judgment module, enlivens connection number upper limit judgment module, overtime connection judgment module, obtains connection pool creation module Take data module;
There are judgment modules for connection pool: judging that the connection pool of data source in access request whether there is, and if it exists, goes to idle connect Judgment module is connect, goes to connection pool creation module if it does not exist;
Connection pool creation module: creating the connection pool of the data source and creates connection, goes to acquisition data module;
Idle connection judgment module: judge in connection pool with the presence or absence of idle connection, and if it exists, then obtain connection, go to acquisition Data module;If it does not exist, then it goes to and enlivens connection number upper limit judgment module;
It enlivens connection number upper limit judgment module: judging to enliven whether connection number reaches the upper limit in connection pool, if it is not, then creation is new Connection, goes to acquisition data module;If so, going to overtime connection judgment module;
Overtime connection judgment module: judging whether there is connection time-out, if so, then removing overtime connection, creates new connection, goes to and obtain Take data module;If no, waiting until there is connection available, acquisition data module is gone to;
It obtains data module: data source is accessed according to access sentence, and according to returning to format to request end returned data.
10. data access system according to claim 7, it is characterised in that: coding is located at the first byte of access request, visits The subsequent byte for asking request is the content after being encoded, and the first byte of parsing module read access request is visited according to code parsing Ask the subsequent byte of request.
CN201910215253.3A 2019-03-21 2019-03-21 Data access method and system supporting multiple programming languages and multiple data sources Active CN109992617B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910215253.3A CN109992617B (en) 2019-03-21 2019-03-21 Data access method and system supporting multiple programming languages and multiple data sources

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910215253.3A CN109992617B (en) 2019-03-21 2019-03-21 Data access method and system supporting multiple programming languages and multiple data sources

Publications (2)

Publication Number Publication Date
CN109992617A true CN109992617A (en) 2019-07-09
CN109992617B CN109992617B (en) 2022-08-26

Family

ID=67129145

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910215253.3A Active CN109992617B (en) 2019-03-21 2019-03-21 Data access method and system supporting multiple programming languages and multiple data sources

Country Status (1)

Country Link
CN (1) CN109992617B (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111259037A (en) * 2020-01-14 2020-06-09 重庆特斯联智慧科技股份有限公司 Data query method and device based on rule configuration, storage medium and terminal
CN114064684A (en) * 2021-10-13 2022-02-18 中国电子科技集团公司第十五研究所 Unified access method for heterogeneous data sources

Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107818127A (en) * 2017-09-09 2018-03-20 国网浙江省电力公司 A kind of querying method and system for multi-source data

Patent Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107818127A (en) * 2017-09-09 2018-03-20 国网浙江省电力公司 A kind of querying method and system for multi-source data

Non-Patent Citations (3)

* Cited by examiner, † Cited by third party
Title
戴长秀: "连接池访问数据库的研究与应用", 《计算机时代》 *
章邢等: "基于OCI和对象池技术的跨平台Oracle数据源管理中间件的实现", 《信息化研究》 *
金弟等: "基于跨平台的Oracle数据库连接研究", 《杭州电子科技大学学报》 *

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111259037A (en) * 2020-01-14 2020-06-09 重庆特斯联智慧科技股份有限公司 Data query method and device based on rule configuration, storage medium and terminal
CN111259037B (en) * 2020-01-14 2023-09-19 重庆特斯联智慧科技股份有限公司 Data query method and device based on rule configuration, storage medium and terminal
CN114064684A (en) * 2021-10-13 2022-02-18 中国电子科技集团公司第十五研究所 Unified access method for heterogeneous data sources

Also Published As

Publication number Publication date
CN109992617B (en) 2022-08-26

Similar Documents

Publication Publication Date Title
CN104270468B (en) A kind of system of wechat control internet of things equipment
US7099950B2 (en) Method and apparatus for using XML for both a protocol layer and application layer
CN105760534B (en) Data structure, hadoop cluster, server and its application method of customized serializability
CN201298231Y (en) Multilingual communication and application system capable of automatically identifying multilanguage
US20050144556A1 (en) XML schema token extension for XML document compression
CN101494621A (en) Translation system and translation method for multi-language instant communication terminal
CN109274773B (en) Method, device and system for realizing remote service calling
CN106341444A (en) Data access method and device
CN109992617A (en) Support the data access method and system of a variety of programming languages and multiple data sources
CN102761532A (en) Information processing system and method for network video
CN102833015B (en) Method for determining public software interface of satellite automatic testing system
CN108664546A (en) Xml data structure conversion method and device
CN107222461A (en) Communication processing method and device
CN100442711C (en) File managing system and method in digital household network
KR102081273B1 (en) Cloud-AI server for generating function control protocols of IOT devices
KR102042688B1 (en) IOT device controlling system
CN104021216A (en) Message proxy server and information publish subscription method and system
CN101764762A (en) Method for providing quickly inputted commonly used phrases in on-line customer service
CN1588968A (en) Method for searching information using mobile terminal short message service
CN101394312B (en) Method and system for managing and parsing XML format uni-disk protocol
US8271668B2 (en) XML in the MASP client-server protocol
CN1145309C (en) Method for managing intelligent network by open interface of service management site
CN114722784A (en) Method for synchronously editing same form in service flow in real time
CN107592321A (en) Single-node login system
CN102314406A (en) The method and system that is used for the lazy data sequenceization of compunication

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant