CN103473311A - Method and device for introducing external database into HTML5 application - Google Patents

Method and device for introducing external database into HTML5 application Download PDF

Info

Publication number
CN103473311A
CN103473311A CN2013104124047A CN201310412404A CN103473311A CN 103473311 A CN103473311 A CN 103473311A CN 2013104124047 A CN2013104124047 A CN 2013104124047A CN 201310412404 A CN201310412404 A CN 201310412404A CN 103473311 A CN103473311 A CN 103473311A
Authority
CN
China
Prior art keywords
data base
external data
copied
local path
path
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
CN2013104124047A
Other languages
Chinese (zh)
Other versions
CN103473311B (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 NEW INTELLIGENCE NETWORK TECHNOLOGY Co Ltd
Original Assignee
BEIJING NEW INTELLIGENCE NETWORK 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 BEIJING NEW INTELLIGENCE NETWORK TECHNOLOGY Co Ltd filed Critical BEIJING NEW INTELLIGENCE NETWORK TECHNOLOGY Co Ltd
Priority to CN201310412404.7A priority Critical patent/CN103473311B/en
Publication of CN103473311A publication Critical patent/CN103473311A/en
Application granted granted Critical
Publication of CN103473311B publication Critical patent/CN103473311B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Abstract

The invention discloses a method and a device for introducing an external database into HTML5 application. The method comprises the steps of confirming a local path for memorizing a local database of the HTML5 application; judging whether the external database exists in the local path or not; copying the external database to the local path if the external database does not exist in the local path; and activating the external database copied in the local path by modifying configuration files of the external database. By adopting the method and the device for introducing the external database into the HTML5 application, the HTML5 application can use the external database without structured query language (SQL) statements, accordingly a user does not worry the speed problem, and the user experience is improved. In addition, data errors caused by user operation are avoided, and furthermore resources of central processing unit (CPU) and an internal memory are saved.

Description

A kind of method and device of introducing external data base in the HTML5 application
Technical field
The present invention relates to the HTML5 technical field, relate in particular to a kind of method and device of introducing external data base in the HTML5 application.
Background technology
HTML (Hypertext Markup Language) (HTML, Hypertext Markup Language) the 5th, the revision version that HTML is next main.Broadly, HTML5 refers to and comprises HTML, CSS (cascading style sheet) (CSS, Cascading Style Sheets) and a set of technical combinations of JavaScript, target is to reduce the demand of browser to the rich network application service of plug-in unit, and provides multipotency more effectively to strengthen the standard of network application.Particularly, HTML5 provides some new element and attributes, comprising " Web SQL Database " (this paper is called the HTML5 local data base), and the embedded database that can visit by SQL statement of this function.In HTML4, database can only can only conduct interviews by server at server end, and, in HTML5, can as the access local file, to embedded database, directly conduct interviews.
When database is the external data base provided by the third party, if realize the access to external data base, method is that this external data base is converted into to SQL statement intuitively, reads SQL statement and carry out in the HTML5 application, thereby generating the data identical with external data base.
The problem that said method exists is poor to the access performance of external data base, and particularly, the speed that SQL statement is carried out is slower, and when especially the data volume in database is larger, slow-footed problem is more outstanding, thereby causes poor user to experience.If the user exits application when SQL statement is carried out, can cause the data in database to make a mistake, because this mistake is that mode of operation by the user causes, therefore can't detect and avoid.In addition, database is converted into to SQL statement, can consumes the resource of CPU and internal memory, and take larger storage space.
Summary of the invention
The invention provides a kind of method and device of introducing external data base in the HTML5 application, to improve the performance in access external data storehouse.
A kind of method of introducing external data base in the HTML5 application, described method comprises:
Determine the local path of HTML5 application preservation local data base;
Judge in described local path and whether have external data base;
If do not exist, described external data base is copied in described local path;
By revising the configuration file of described external data base, activate the external data base copied in described local path.
Preferably, by revising the configuration file of described external data base, activate the external data base copied in described local path and comprise:
Obtain the path of configuration database;
Open described configuration database;
Judge the configuration file that whether comprises the external data base copied in described configuration database;
If described configuration file is arranged, its path field is revised as consistent with the information of the external data base copied, otherwise, a newly-built configuration file, its path field is consistent with the information of the external data base copied.
Alternatively, whether have external data base in judging described local path after, described method also comprises:
If there is described external data base, judge that whether the version of described external data base is higher than the already present external data base of described local path, if higher than, described external data base is copied in described local path, flow process finishes.
Alternatively, before determining that the local path of local data base is preserved in the HTML5 application, described method also comprises:
The environment of described HTML5 application initializes database, and start introducing external data library facility.
Alternatively, at the configuration file by the described external data base of modification, after activating the external data base copied in described local path, described method also comprises:
After described HTML5 application detects the described external data base copied and is activated, carry out the operation of opening database.
A kind of device of introducing external data base in the HTML5 application, described device comprises:
Determining unit, preserve the local path of local data base for determining the HTML5 application;
Whether the first judging unit, exist external data base for judging described local path;
Copied cells, if for not existing, copy to described external data base in described local path;
Activate unit, for by revising the configuration file of described external data base, activate the external data base copied in described local path.
Preferably, described activation unit comprises:
Acquiring unit, for obtaining the path of configuration database;
Open unit, for opening described configuration database;
Whether the second judging unit, comprise the configuration file of the external data base copied for judging described configuration database;
Matching unit, if for described configuration file is arranged, its path field is revised as consistent with the information of the external data base copied, otherwise, a newly-built configuration file, its path field is consistent with the information of the external data base copied.
Alternatively, described device also comprises:
Updating block, for after described the first judgment unit judges goes out to exist described external data base, judge that whether the version of described external data base is higher than the already present external data base of described local path, if higher than, described external data base is copied in described local path.
As can be seen here, the present invention copies to external data base in local path, and the external data base copied is activated, thereby can use external data base, whole process is without carrying out by SQL statement, thereby make the user without worrying speed issue, improved user's experience, and avoided the error in data caused due to user's operation, in addition, also saved CPU and memory source.Also it is pointed out that the present invention can also judge whether the more external data base of highest version, so the database that the present invention can also use the HTML5 application is upgraded.
The accompanying drawing explanation
By the description to embodiment below in conjunction with accompanying drawing, the present invention will become and obviously and more easily be understood.For convenience, accompanying drawing shows presently preferred embodiment of the present invention; Yet, be understandable that, the invention is not restricted to shown clear and definite step and unit.Accompanying drawing comprises:
The method flow diagram that Fig. 1 provides for the embodiment of the present invention one;
The method flow diagram that Fig. 2 provides for the embodiment of the present invention two;
The device block diagram that Fig. 3 provides for the embodiment of the present invention three;
The device block diagram that Fig. 4 provides for the embodiment of the present invention four.
Embodiment
Hereinafter, will to exemplary embodiment of the present invention, be described in detail with reference to the accompanying drawings.
Before the description to detailed describes, should be appreciated that, the term and the word that are used in this instructions and claim may be not limited to its ordinary meaning or dictionary implication, but can use neologisms to explain in the best way under principle of the present invention the inventor, be interpreted as being suitable for implication or the concept of the technology of the present invention scope.
The invention provides embodiment makes openly fully and contains those skilled in the art fully.To detail for example concrete steps, device set forth, thoroughly to understand the present embodiment.For a person skilled in the art, obviously, do not need to adopt concrete details, embodiment can carry out imbody in many different forms, and should not be interpreted as limitation of the scope of the invention.In certain embodiments, known technology is not described in detail.
Therefore, the embodiment that this instructions is described and the structure shown in accompanying drawing only for setting forth embodiments of the invention in the technology of the present invention scope.Those skilled in the art should understand that can make various equivalences replaces and revise replacement embodiment.
The HTML5 application is a kind of client software, can adopt the hybrid programming system.For ease of understanding the present invention, this section describes the hybrid programming system the present invention relates to.At first, HTML5 is the standard that a kind of client end interface is showed and programmed, and can adopt JavaScript to write.The hybrid programming system the present invention relates to refers to partial code and uses HTML5 to write, and partial code is used high-level programming language to write (high-level programming language write function be commonly referred to plug-in unit).Its principal feature comprises: 1. most of function adopts JavaScript to realize; 2. for different equipment, the high-level programming language difference of employing, for example, used the equipment of Android system, adopts Java to write, and uses the equipment of iOS system, adopts Object C to write; 3. the function of using high-level programming language to write, can provide application programming interfaces (API, Application Program Interface), and JavaScript can carry out the function that high-level programming language is write by calling API.
External data base is kept in the installation path of HTML5 application at first, and the HTML5 application is the access external data storehouse directly.The implication that the present invention introduces HTML5 application by external data base is: external data base is copied in the path of HTML5 application appointment and by its activation, the HTML5 application just can directly be used external data base like this, now, external data base has been converted into the interior database of the database system of HTML5 application oneself.
Please refer to Fig. 1, the method flow diagram for the embodiment of the present invention one provides can comprise the following steps:
Step 101: the local path of determining HTML5 application preservation local data base;
Step 102: judge in local path and whether have external data base;
Step 103: if do not exist, external data base is copied in local path;
Step 104: by revising the configuration file of external data base, activate the external data base copied in local path.
As can be seen here, method provided by the invention by above-mentioned steps without by SQL statement, just using external data base, thereby make the user without worrying speed issue, improved user's experience, and avoided the error in data caused due to user's operation, in addition, also saved CPU and memory source.
Below in conjunction with another embodiment, the present invention is further described in more detail.
Please refer to Fig. 2, the method flow diagram for the embodiment of the present invention two provides can comprise the following steps:
The environment of step 201:HTML5 application initializes database;
It is that the function of database is carried out that the environment of database is carried out to initialized purpose, otherwise, can't carry out subsequent step.
Particularly, the environment in initialization data storehouse can be realized by opening newly-built database.For example, can use following code (wherein, Xxtebook is newly-built database name):
Figure BDA0000380508870000051
Step 202:HTML5 application start is introduced the external data library facility;
Particularly, the HTML5 application start is introduced the external data library facility and can be realized by API Calls the first plug-in unit, and described the first plug-in unit can be introduced external data base (hereinafter being elaborated) by replicate run and activation manipulation.Different hybrid programming systems, call the mode difference of plug-in unit, and the mobile application development platform phonegap of mobile device of take is example, calls the first plug-in unit and can realize by following code:
window.plugins.xxtEbookInit.startup(startupWin,fail);
Step 203: the first plug-in unit is determined the local path of HTML5 application preservation local data base;
The path difference in different equipment or browser core save data storehouse, particularly, can determine this path by document, for the purpose of facilitating, this path is called to local path herein, i.e. the path of previously mentioned HTML5 application appointment.
Step 204: the first plug-in unit judges in local path whether have external data base, if exist, flow process finishes, otherwise enters step 205;
The implication of " flow process end " is herein: during the each startup of HTML5 application, the JavaScript code is first carried out in capital, JavaScript and then call the first plug-in unit, if introduced external data base, in order to save time and to maintain the self-defined information that the user adds in database, without again introducing.If, but external data base has higher version, can be reintroduced back to external data base, therefore, can to the external data base of introducing, be upgraded in the following way.
Alternatively, if there is external data base in local path, the first plug-in unit further judges that whether the version of external data base is higher than the already present external data base of local path, if higher than, enter step 205, otherwise flow process finishes.
Step 205: the first plug-in unit copies to external data base in local path;
The described process copied can be the reproduction process of binary file.
Step 206: the first plug-in unit, by revising the configuration file of external data base, activates the external data base copied in local path;
Activation is closely related with mobile phone operating system, and different systems activates the concrete grammar difference of the external data base copied.The Webkit system is kept at the configuration file of database in the Database database, therefore, needs the configuration file of revising in the Database database just can activate the external data base copied.For the equipment that uses the Android system, the first plug-in unit can activate the external data base copied by following steps:
Step 206-1: the path that obtains configuration database;
Configuration database is a database of the database of management HTML5, and its name is Databases.db, and its path is kept in the db_path variable, and different systems, db_path variable difference.
Step 206-2: open configuration database;
Step 206-3: judge the configuration file that whether comprises the external data base copied in configuration database;
Step 206-4: if described configuration file is arranged, its path field is revised as consistent with the information of the external data base copied, otherwise, a newly-built configuration file, its path field is consistent with the information of the external data base copied.
To step 206-4, just can activate the external data base copied by step 206-1, thereby make HTML5 can use external data base.Particularly, can realize by following code:
Figure BDA0000380508870000071
Figure BDA0000380508870000081
After step 207:HTML5 application detects the external data base copied and is activated, again carry out the operation of opening database, to use external data base.
Particularly, can realize by following code:
db=window.openDatabase("xxtebook","1.0","Xxtebook?Database",1*1024*1024);
Pass through above-mentioned steps, can find out, the present invention copies to external data base in local path, and the external data base copied is activated, thereby can use external data base, whole process is without carrying out by SQL statement, thereby make the user without worrying speed issue, improved user's experience, and avoided the error in data caused due to user's operation, in addition, CPU and memory source have also been saved.Also it is pointed out that because the first plug-in unit can also judge whether the more external data base of highest version, so the database that the present invention can also use the HTML5 application is upgraded.
Please refer to Fig. 3, the device block diagram for the embodiment of the present invention three provides can comprise:
Determining unit 301, preserve the local path of local data base for determining the HTML5 application;
Whether the first judging unit 302, exist external data base for judging local path;
Copied cells 303, if for not existing, copy to external data base in local path;
Activate unit 304, for by revising the configuration file of external data base, activate the external data base copied in local path.
Please refer to Fig. 4, the device block diagram provided for the embodiment of the present invention four.
Described activation unit 304 can comprise:
Acquiring unit 401, for obtaining the path of configuration database;
Open unit 402, for opening described configuration database;
Whether the second judging unit 403, comprise the configuration file of the external data base copied for judging described configuration database;
Matching unit 404, if for described configuration file is arranged, its path field is revised as consistent with the information of the external data base copied, otherwise, a newly-built configuration file, its path field is consistent with the information of the external data base copied.
Fig. 3 shown device can also comprise:
Updating block 405, for after described the first judging unit 302 is judged and is had described external data base, judge that whether the version of described external data base is higher than the already present external data base of described local path, if higher than, described external data base is copied in described local path.
Can find out, the present invention copies to external data base in local path, and the external data base copied is activated, thereby can use external data base, whole process is without carrying out by SQL statement, thereby make the user without worrying speed issue, improved user's experience, and avoided the error in data caused due to user's operation, in addition, also saved CPU and memory source.Also it is pointed out that because the first plug-in unit can also judge whether the more external data base of highest version, so the database that the present invention can also use the HTML5 application is upgraded.
Term used herein is only in order to describe specific embodiment, and meaning is not in restriction.As used herein, unless context is clear, point out, term " comprises " and comprising, therefore describe feature, integral body, step, operation, element and/or the parts of statement in detail, do not get rid of the existence of one or more other feature, integral body, step, operation, element, parts and/or its combination or additional.
Although first, second can be used for describing various parts term, these parts should not limited by these terms.These terms can only be used for parts and the difference of another parts are come.Unless context clearly points out, when using the such term of for example " first ", " second " and other digital term, do not infer sequence or order.Therefore, in the situation that do not deviate from the principle of embodiment, the first component of description can be called as second component.
It is to describe that the description purpose of the present embodiment is provided, and meaning is not in limit or restriction the present invention.Single step or parts are not limited in this embodiment, even without specifically illustrating or being described, also can be exchanged in the embodiment of applicable selection and use.Can also be changed according to many modes, these variations do not break away from the present invention, and all these changes are intended within the scope of the present invention.

Claims (8)

1. a method of introducing external data base in the HTML5 application, is characterized in that, described method comprises:
Determine the local path of HTML5 application preservation local data base;
Judge in described local path and whether have external data base;
If do not exist, described external data base is copied in described local path;
By revising the configuration file of described external data base, activate the external data base copied in described local path.
2. method according to claim 1, is characterized in that, by revising the configuration file of described external data base, activates the external data base copied in described local path and comprise:
Obtain the path of configuration database;
Open described configuration database;
Judge the configuration file that whether comprises the external data base copied in described configuration database;
If described configuration file is arranged, its path field is revised as consistent with the information of the external data base copied, otherwise, a newly-built configuration file, its path field is consistent with the information of the external data base copied.
3. method according to claim 1, is characterized in that, whether have external data base in judging described local path after, described method also comprises:
If there is described external data base, judge that whether the version of described external data base is higher than the already present external data base of described local path, if higher than, described external data base is copied in described local path, flow process finishes.
4. method according to claim 1, is characterized in that, before determining that the local path of local data base is preserved in the HTML5 application, described method also comprises:
The environment of described HTML5 application initializes database, and start introducing external data library facility.
5. method according to claim 1, is characterized in that, at the configuration file by the described external data base of modification, after activating the external data base copied in described local path, described method also comprises:
After described HTML5 application detects the described external data base copied and is activated, carry out the operation of opening database.
6. a device of introducing external data base in the HTML5 application, is characterized in that, described device comprises:
Determining unit, preserve the local path of local data base for determining the HTML5 application;
Whether the first judging unit, exist external data base for judging described local path;
Copied cells, if for not existing, copy to described external data base in described local path;
Activate unit, for by revising the configuration file of described external data base, activate the external data base copied in described local path.
7. device according to claim 6, is characterized in that, described activation unit comprises:
Acquiring unit, for obtaining the path of configuration database;
Open unit, for opening described configuration database;
Whether the second judging unit, comprise the configuration file of the external data base copied for judging described configuration database;
Matching unit, if for described configuration file is arranged, its path field is revised as consistent with the information of the external data base copied, otherwise, a newly-built configuration file, its path field is consistent with the information of the external data base copied.
8. device according to claim 6, is characterized in that, described device also comprises:
Updating block, for after described the first judgment unit judges goes out to exist described external data base, judge that whether the version of described external data base is higher than the already present external data base of described local path, if higher than, described external data base is copied in described local path.
CN201310412404.7A 2013-09-11 2013-09-11 A kind of method and device introducing external data base in HTML5 applies Active CN103473311B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201310412404.7A CN103473311B (en) 2013-09-11 2013-09-11 A kind of method and device introducing external data base in HTML5 applies

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201310412404.7A CN103473311B (en) 2013-09-11 2013-09-11 A kind of method and device introducing external data base in HTML5 applies

Publications (2)

Publication Number Publication Date
CN103473311A true CN103473311A (en) 2013-12-25
CN103473311B CN103473311B (en) 2016-10-12

Family

ID=49798159

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201310412404.7A Active CN103473311B (en) 2013-09-11 2013-09-11 A kind of method and device introducing external data base in HTML5 applies

Country Status (1)

Country Link
CN (1) CN103473311B (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104462463A (en) * 2014-12-17 2015-03-25 南京莱斯信息技术股份有限公司 JavaScript data access method based on SQL template

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP1686498A2 (en) * 2005-01-31 2006-08-02 Microsoft Corporation Integration of a non-relational query language with a relational data store
WO2007061430A1 (en) * 2005-11-22 2007-05-31 Bea Systems, Inc. System and method for translating sql queries into xml query language
CN102053822A (en) * 2009-10-27 2011-05-11 上海杉达学院 Method and device for connecting Java information platform and SQL Server database
CN102402626A (en) * 2011-12-28 2012-04-04 用友软件股份有限公司 System and method for dynamically querying inheritance data of version

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP1686498A2 (en) * 2005-01-31 2006-08-02 Microsoft Corporation Integration of a non-relational query language with a relational data store
WO2007061430A1 (en) * 2005-11-22 2007-05-31 Bea Systems, Inc. System and method for translating sql queries into xml query language
CN102053822A (en) * 2009-10-27 2011-05-11 上海杉达学院 Method and device for connecting Java information platform and SQL Server database
CN102402626A (en) * 2011-12-28 2012-04-04 用友软件股份有限公司 System and method for dynamically querying inheritance data of version

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104462463A (en) * 2014-12-17 2015-03-25 南京莱斯信息技术股份有限公司 JavaScript data access method based on SQL template
CN104462463B (en) * 2014-12-17 2018-08-14 南京莱斯信息技术股份有限公司 Data access methods of the JavaScript based on SQL templates

Also Published As

Publication number Publication date
CN103473311B (en) 2016-10-12

Similar Documents

Publication Publication Date Title
US10990367B2 (en) Application development method, tool, and device, and storage medium
US8856805B2 (en) Virtual channel for embedded process communication
US8516037B2 (en) Methods for dynamic partitioning of applications in client-server environments
US10447814B2 (en) Joint servicing of software packages
US9244702B1 (en) Installer-free applications using native code modules and persistent local storage
CN109065054A (en) Speech recognition error correction method, device, electronic equipment and readable storage medium storing program for executing
US20100251084A1 (en) Input content to application via web browser
US9781262B2 (en) Methods and apparatus for voice-enabling a web application
US9400633B2 (en) Methods and apparatus for voiced-enabling a web application
US10157612B2 (en) Methods and apparatus for voice-enabling a web application
US20140040746A1 (en) Methods and apparatus for voiced-enabling a web application
KR101482150B1 (en) Web application executable device and web application management method therof
US9513762B1 (en) Static content updates
CN106326129A (en) Program abnormity information generating method and device
CN106502707B (en) Code generation method and device
CN110941443B (en) Method and device for modifying file name in SDK (software development kit) and electronic equipment
CN103473311A (en) Method and device for introducing external database into HTML5 application
JP2011243213A (en) Managing multiple languages in data language
RU2697951C2 (en) System and method of terminating functionally restricted application, interconnected with website, launched without installation
CN105610908B (en) A kind of samba service implementing method and system based on Android device
CN110874322A (en) Test method and test server for application program
US20080307446A1 (en) Interoperable Managed and Unmanaged Code in a Document Environment
CN115203149A (en) File processing method and device
CN112286545A (en) Data updating method, device, equipment and storage medium
CN118034652A (en) Method for automatically generating service codes

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
C14 Grant of patent or utility model
GR01 Patent grant