Interaction method, device, medium and system for business system and third-party database
By dynamically running JavaScript code and AOP technology, decoupling third-party interfaces and database logic is solved, and the problem of tight coupling between main projects and third-party databases in traditional software development is improved, the flexibility and maintainability of the system is realized, and cross-platform Data interaction and efficient development.
Patent Information
- Application Number
- CN202411412103.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-10
- Publication Date
- 2025-01-17
AI Technical Summary
In traditional software development methods, the main project is closely coupled with the third-party database, resulting in high complexity of the project, which is not conducive to maintenance and upgrades. When the third-party interface or database changes, the main project needs to be modified a large number of times, affecting stability and scalability.
It uses dynamically run JavaScript code, uses the Nashorn engine and aspect-oriented programming (AOP) features to decouple third-party interface calls and database reading logic, and interacts with third-party databases through JavaScript scripts to reduce the intrusion and complexity of the main project.
It improves the flexibility and maintainability of the software system, facilitates modification and expansion of third-party data interaction logic, enhances portability and development efficiency, and avoids writing a large amount of redundant code in the main project.
Smart Images

Figure CN119322802A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a method, device, medium and system for interaction between a business system and a third-party database. Background Art
[0002] With the rapid development of science and technology in recent years, various applications have emerged, and with the continuous increase and concretization of user needs, the frequency of application updates is also getting faster and faster.
[0003] In the process of software development, it is often necessary to call third-party interfaces or read information from third-party databases to meet business needs. Traditional development methods usually require all relevant business logic to be written directly into the main project. This method not only increases the complexity of the project, but also makes the project tightly coupled with third-party data, which is not convenient for subsequent maintenance and upgrades. When the third-party interface or database changes, it is often necessary to make a lot of modifications to the main project, affecting the stability and scalability of the main project of the application. Summary of the invention
[0004] The embodiments of the present application provide a method, device, medium and system for interaction between a business system and a third-party database. This solution can solve the problems existing in the prior art, such as the high complexity of the main project in the software development process, and the tight coupling with the third-party data, which is not conducive to subsequent maintenance and upgrading. The invention proposes a system and method for dynamically running JavaScript code to realize third-party data interaction. The system and method utilize the Nashorn engine and aspect-oriented programming (AOP) features to achieve the decoupling of third-party interface calls and database reading logic, thereby improving the flexibility and maintainability of the software system.
[0005] The embodiment of the present application provides a method for interaction between a business system and a third-party database, the method comprising:
[0006] Receive user requests sent by users in the business system;
[0007] During the operation of the business system, if it is identified that the business system is running to a preset cut-off point, the target JavaScript script corresponding to the current preset cut-off point is called through the Nashorn engine;
[0008] Executing the target JavaScript script in the Nashorn engine to interact with a third-party database through the target JavaScript script;
[0009] A business response is made to the user request according to the interactive data returned by the target JavaScript script of the preset cut-off point.
[0010] Furthermore, before receiving the user request sent by the user in the business system, it also includes:
[0011] In response to the configuration operation of the JavaScript script, the JavaScript script is configured; wherein the configuration includes at least one of the interface parameters, request mode and data processing logic required for configuring the third-party database interface, and at least one of the connection information, query statement and result parsing logic required for configuring the third-party database;
[0012] After the JavaScript script configuration is completed, the JavaScript script is imported into the business system so that the JavaScript script is called when the business system runs to a preset cut-off point and issues a call instruction.
[0013] Further, executing the target JavaScript script in the Nashorn engine to interact with a third-party database through the target JavaScript script includes:
[0014] The target JavaScript script is executed in the Nashorn engine to directly operate the third-party database through the JavaScript code of the target JavaScript script to interact with the third-party database.
[0015] Further, executing the target JavaScript script in the Nashorn engine to interact with a third-party database through the target JavaScript script includes:
[0016] The target JavaScript script is executed in the Nashorn engine, and the file reading and writing interface provided by the Nashorn engine is used to directly read and write files when the target JavaScript script interacts with a third-party database, and the image loading and processing interface provided by the Nashorn engine is used to directly load and process images when the target JavaScript script interacts with the third-party database.
[0017] Further, the Nashorn engine executes the JavaScript code of the JavaScript script using the engine.eval() method;
[0018] The Nashorn engine calls functions in JavaScript scripts through the Invocable interface.
[0019] Furthermore, during the operation of the business system, if it is identified that the business system is running to a preset cut-off point, before the target JavaScript script corresponding to the current preset cut-off point is called by the Nashorn engine, the following is also included:
[0020] The JavaScript code of the JavaScript script is configured through the pointcut configurator, and the business method associated with the JavaScript code is defined to control the JavaScript code to be executed in the business method, or before the business method, or after the business method.
[0021] Furthermore, during the operation of the business system, if it is identified that the business system is running to a preset cut-off point, before the target JavaScript script corresponding to the current preset cut-off point is called by the Nashorn engine, the following is also included:
[0022] The newly added JavaScript code of the JavaScript script is configured through the cut-off point configurator to update the JavaScript script.
[0023] The embodiment of the present application provides an interactive device between a business system and a third-party database, the device comprising:
[0024] A user request receiving module is used to receive a user request sent by a user in the business system;
[0025] The calling module is used to call the target JavaScript script corresponding to the current preset cut-off point through the Nashorn engine if the business system is identified to be running to the preset cut-off point during the operation of the business system;
[0026] An execution module, used for executing the target JavaScript script in the Nashorn engine, so as to interact with a third-party database through the target JavaScript script;
[0027] The business response module is used to perform a business response to the user request according to the interactive data returned by the target JavaScript script of the preset cut-off point.
[0028] The embodiment of the present application also provides a computer-readable storage medium on which a computer program is stored. When the program is executed by a processor, the method for interaction between the business system and the third-party database as described in the embodiment of the present application is implemented.
[0029] The embodiment of the present application also provides an interactive system between a business system and a third-party database, and the interactive system between a business system and a third-party database is used to execute the interactive method between a business system and a third-party database as described in the embodiment of the present application.
[0030] An embodiment of the present application also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the method for interacting between the business system and a third-party database as provided in the embodiment of the present application is implemented.
[0031] At least one of the above technical solutions adopted in the embodiments of the present application can achieve the following beneficial effects:
[0032] The technical solution provided by the present application can reduce intrusiveness, that is, by separating the JavaScript script from the main project, the intrusiveness of the third-party data interaction on the main project is reduced, and the maintainability of the project is improved; the flexibility is improved. By utilizing the flexibility of the JavaScript script, the third-party data interaction logic can be easily modified and expanded to meet the ever-changing business needs; the portability is enhanced. Due to the cross-platform nature of the JavaScript script, the technical solution of the present invention can be easily ported to different software systems to achieve cross-platform data interaction; the development efficiency is improved. By dynamically executing the JavaScript script, a large amount of redundant code can be avoided in the main project, thereby improving the development efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0033] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:
[0034] Figure 1 It is a flowchart of the interaction method between the business system and the third-party database provided in Example 1 of the present application;
[0035] Figure 2 It is a schematic diagram of the JavaScript script configuration process provided in Example 1 of the present application;
[0036] Figure 3 This is a flow chart of interacting with a third-party database through a JavaScript script provided in the first embodiment of the present application;
[0037] Figure 4 It is a structural diagram of an interactive device between a business system and a third-party database provided in Embodiment 2 of the present application;
[0038] Figure 5 It is a structural schematic diagram of an electronic device provided in Example 5 of the present application. DETAILED DESCRIPTION
[0039] In order to make the purpose, technical solution and advantages of the present application clearer, the technical solution of the present application will be clearly and completely described below in combination with the specific embodiments of the present application and the corresponding drawings. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present application.
[0040] The technical solutions provided by various embodiments of the present application are described in detail below in conjunction with the accompanying drawings.
[0041] Embodiment 1
[0042] Figure 1 It is a flow chart of the method for interaction between a business system and a third-party database provided in the first embodiment of the present application. This embodiment can be applicable to software development. The method can be executed by the device for interaction between a business system and a third-party database provided in the embodiment of the present application. The device can be implemented by software and / or hardware, and can be integrated into an electronic device used for interaction between a business system and a third-party database.
[0043] like Figure 1 As shown, the method includes:
[0044] S110, receiving a user request sent by a user in a business system;
[0045] The business system can be a system where the developed software runs, which can receive user requests, respond to user requests, and obtain the result products required by the user to use the software. For example, the business system can be a system that provides users with image processing, a system for ordering food, etc.
[0046] Users can send user requests through mobile terminals or other smart terminal devices, such as opening a certain software and completing an order or query in it.
[0047] S120, during the operation of the business system, if it is identified that the business system is running to a preset cut-off point, the target JavaScript script corresponding to the current preset cut-off point is called through the Nashorn engine;
[0048] The process by which the business system responds to user requests to obtain the final product is the operation process. It can be understood that in the same software, different user requests can have different operation processes, and multiple operation processes can be carried out simultaneously.
[0049] For each user request response running process, one or more preset cut-off points may be set. The preset cut-off points may be used to run JavaScript scripts to interact with a third-party database. The number of preset cut-off points may be related to the number or quantity of interactions with the third-party database required during the current user request response running process.
[0050] Similarly, a preset cut-off point can be pre-set with multiple JavaScript scripts, and one or more can be determined as the target JavaScript script according to actual needs during the running process. For the convenience of design, all JavaScript scripts can be set in a script pool, so that when running to the preset cut-off point in any running process, one or more JavaScript scripts can be called from the script pool according to needs. In another feasible scheme, a fixed design can be made for each preset cut-off point of each running process. For example, if the current user request is a request for a food order, two preset cut-off points can be set during the running process. The target JavaScript script to be used at each preset cut-off point can be fixed. In this way, the process of determining the target JavaScript script according to the user request or response process can be avoided during the running process, thereby improving the response efficiency of the business system.
[0051] When running to the preset cut-off point, the target JavaScript script corresponding to the current preset cut-off point is called through the Nashorn engine.
[0052] The Nashorn engine is a new JavaScript engine introduced in Java 8. With high performance, Nashorn is faster in executing JavaScript code than the traditional Rhino engine and can handle large-scale JavaScript applications more efficiently. It takes advantage of the optimization and parallel processing capabilities of the Java Virtual Machine (JVM) to improve the execution efficiency of scripts. The Nashorn engine is tightly integrated with Java. Nashorn allows JavaScript functions and objects to be easily called in Java code, while Java objects and methods can also be accessed in JavaScript code. This integration allows developers to use the flexibility and dynamism of JavaScript in Java applications to implement more complex business logic. Supporting new JavaScript language features, Nashorn supports the ECMAScript 5.1 specification and some ECMAScript 6 features, such as arrow functions and template strings. This allows developers to write scripts using more modern JavaScript syntax and improve development efficiency. Specific application scenarios can include: server-side scripts. On the server side, Nashorn can be used to process dynamically generated content, perform data processing tasks, or implement server-side business logic. For example, Nashorn can be used to write server-side JavaScript scripts to process HTTP requests, generate dynamic web page content, or interact with databases. Command line tools and scripts. Nashorn can be used as a command line tool to execute independent JavaScript scripts, or combined with other command line tools to automate tasks and system management. Developers can use Nashorn to write scripts for file operations, system monitoring, task scheduling, etc. Testing and automation. In the field of testing, Nashorn can be used to write test scripts and automate testing of Java applications. The flexibility and dynamism of JavaScript can be used to simulate user behavior and verify the functionality and performance of applications.
[0053] S130, executing the target JavaScript script in the Nashorn engine, so as to interact with a third-party database through the target JavaScript script;
[0054] In this solution, the target JavaScript script can be used to interact with a third-party database to obtain interactive data. Specifically, the target JavaScript script can send a data query request to the third-party database, and after the third-party database completes the data query operation, it feeds back the queried interactive data.
[0055] JavaScript is a high-level programming language widely used in web development. JavaScript is an interpreted language that can be executed directly in the browser without compilation. This makes the development process faster and more convenient, and developers can immediately see the effect of the code, debug and modify it. The characteristics of interpreted languages also allow JavaScript to dynamically modify the code and achieve more flexible interactive effects. JavaScript is a weakly typed language, and the type of variables can be changed dynamically at runtime. This allows developers to process data more flexibly without explicitly specifying the type of variables in the code. The characteristics of weakly typed languages also make JavaScript code more concise and easy to read, but at the same time, developers also need to pay more attention to type conversion and error handling. JavaScript is an object-oriented language that supports object-oriented programming concepts such as encapsulation, inheritance, and polymorphism. This allows developers to use object-oriented methods to organize and manage code and improve the maintainability and scalability of the code. Objects in JavaScript can be created by literals, constructors, or prototype chains. Developers can choose the appropriate way to create objects according to specific needs. JavaScript is an event-driven programming language that triggers the execution of corresponding code by listening to user operations and browser events. This allows web pages to achieve richer interactive effects, such as mouse clicks, keyboard input, page loading, and other events can trigger the execution of JavaScript code. The characteristics of event-driven programming also make JavaScript code more modular and maintainable. Developers can encapsulate different event processing logic in different functions to improve the readability and maintainability of the code.
[0056] JavaScript can run on different operating systems and browsers, and has strong cross-platform capabilities. This allows developers to use the same code to achieve the same functions on different platforms, reducing the cost of development and maintenance. Cross-platform also makes JavaScript one of the preferred languages for web development, because web pages can be accessed on any device that supports a browser. JavaScript has a wealth of libraries and frameworks, such as jQuery, React, Angular, etc. These libraries and frameworks can greatly improve development efficiency and reduce development time. Developers can choose appropriate libraries and frameworks according to specific needs to implement the functions of web pages and improve the quality and maintainability of the code. JavaScript can be closely integrated with HTML and CSS to achieve richer web page effects. Developers can use JavaScript to manipulate HTML elements and CSS styles to achieve dynamic page effects and interactive functions. The close integration with HTML and CSS also makes JavaScript an important part of web development. Developers need to master the basic knowledge and skills of these three languages to achieve high-quality web development.
[0057] JavaScript is one of the core languages for web development, which can realize dynamic effects, interactive functions and data processing of web pages. Developers can use JavaScript to manipulate HTML elements and CSS styles to realize the layout and style design of web pages. Common applications in web development include form validation, animation effects, data visualization, AJAX asynchronous requests, etc. JavaScript can also be used for mobile application development. By using frameworks such as React Native and Ionic, JavaScript can be used to develop cross-platform mobile applications. Common applications in mobile application development include interface design, data storage, network requests, push notifications, etc. JavaScript can also be used for server-side development. By using frameworks such as Node.js, JavaScript can be used to develop high-performance server-side applications. Common applications in server-side development include web servers, database operations, file system operations, network communications, etc. JavaScript can also be used for desktop application development. By using frameworks such as Electron, JavaScript can be used to develop cross-platform desktop applications. Common applications in desktop application development include interface design, file system operations, network communications, system notifications, etc.
[0058] S140: Perform a business response to the user request according to the interactive data returned by the target JavaScript script of the preset cut-off point.
[0059] After the target JavaScript script obtains the interactive data, it returns the interactive data to the business system, and after the business system completes all processes of the current user request, it returns the result data to the user end to implement the business response to the user request.
[0060] The technical solution provided in this embodiment receives a user request issued by a user in a business system; during the operation of the business system, if it is identified that the business system is running to a preset cut-off point, the target JavaScript script corresponding to the current preset cut-off point is called through the Nashorn engine; the target JavaScript script is executed in the Nashorn engine to interact with a third-party database through the target JavaScript script; and a business response is made to the user request based on the interaction data returned by the target JavaScript script at the preset cut-off point. By adopting this solution, the JavaScript script can be separated from the main project, thereby reducing the intrusiveness of the third-party data interaction to the main project and improving the maintainability of the project; improving flexibility, using the flexibility of the JavaScript script, the third-party data interaction logic can be easily modified and expanded to meet the ever-changing business needs; enhancing portability, due to the cross-platform nature of the JavaScript script, the technical solution of the present invention can be easily ported to different software systems to achieve cross-platform data interaction; improving development efficiency, by dynamically executing JavaScript scripts, avoiding the writing of a large amount of redundant code in the main project, thereby improving development efficiency.
[0061] In this embodiment, optionally, before receiving a user request sent by a user in the business system, the method further includes:
[0062] In response to the configuration operation of the JavaScript script, the JavaScript script is configured; wherein the configuration includes at least one of the interface parameters, request mode and data processing logic required for configuring the third-party database interface, and at least one of the connection information, query statement and result parsing logic required for configuring the third-party database;
[0063] After the JavaScript script configuration is completed, the JavaScript script is imported into the business system so that the JavaScript script is called when the business system runs to a preset cut-off point and issues a call instruction.
[0064] Among them, the configuration of JavaScript scripts can be configured according to the actual needs of the current software. For example, if the current software needs to cooperate with three third-party databases A, B, and C, three JavaScript scripts can be pre-configured to interact with the three third-party databases A, B, and C respectively, and obtain the interaction data of the three third-party databases A, B, and C to meet the corresponding needs of the current user request.
[0065] In this solution, specifically, at least one of the interface parameters, request methods, and data processing logic required by the third-party database interface can be configured, and at least one of the connection information, query statements, and result parsing logic required by the third-party database can be configured.
[0066] The interface parameters required by the third-party database interface often vary depending on the specific database and interface type. Common parameters are:
[0067] 1. Authentication related parameters:
[0068] Username: The user name used to log in to the database, usually assigned by the database administrator.
[0069] Password: The password corresponding to the username is used to verify the user's identity.
[0070] API key: Some databases may provide API keys as an authentication method. The key is usually a unique sequence of characters used to identify and authorize users who call the interface.
[0071] 2. Database connection parameters;
[0072] Database address (host), the IP address or domain name of the database server, used to establish a connection with the database.
[0073] Port number (port), the port number that the database server listens on. Different databases may use different default port numbers. For example, MySQL usually uses port 3306, and PostgreSQL usually uses port 5432.
[0074] Database name: the name of the specific database to connect to.
[0075] 3. Data operation parameters:
[0076] Table name: If you want to operate on a specific table, you need to specify the table name.
[0077] Query conditions are used to specify the conditions for data query, such as the conditional expression in the WHERE clause. It can be a single condition or a combination of multiple conditions.
[0078] Sort field: specifies the sort field for the query results, which can be in ascending order (ASC) or descending order (DESC).
[0079] Pagination parameters: If the amount of data is large, pagination query may be required. Common pagination parameters include the number of records displayed per page (page size) and the current page number (page number).
[0080] 4. Data format parameters:
[0081] Return format: specifies the format of the data returned by the interface, such as JSON, XML, etc.
[0082] Date time format: If the database contains date time fields, you may need to specify the date time format so that it can be parsed and displayed correctly.
[0083] 5. Other parameters:
[0084] Timeout: Set the connection timeout and query timeout to prevent long waiting times without response.
[0085] The maximum number of connections (max connections) limits the maximum number of simultaneous connections to the database to avoid resource exhaustion.
[0086] Caching settings: Some interfaces may support caching data to improve query performance. Related parameters may include cache validity period, cache size, etc.
[0087] It should be noted that the specific interface parameters will be determined according to the documents and interface specifications provided by the third-party database. When using the third-party database interface, you can first understand the required parameters and their meanings to ensure that the interface is called correctly and the required data is obtained.
[0088] There are usually the following ways to request a third-party database:
[0089] 1. HTTP request:
[0090] GET request:
[0091] Typically used to retrieve data. You send a GET request to the database's endpoint, specifying a specific resource path and possible query parameters.
[0092] For example, to get a list of users, you might send a GET request to / users, and you can add query parameters such as / users? page=2&limit=10 to the URL to specify paging information.
[0093] The advantages are that it is simple and intuitive, and can be tested directly in the browser address bar. The disadvantage is that it is not suitable for transmitting large amounts of data or sensitive information because the parameters will be visible in the URL.
[0094] POST request:
[0095] Commonly used to create new data records. You send data to the database interface in a specific format (such as JSON or form data).
[0096] For example, to create a new user, you can send a POST request to / users and include the user's information in the request body.
[0097] The advantage is that a large amount of data can be transmitted without exposing the data in the URL. The disadvantage is that it is slightly more complicated than a GET request.
[0098] PUT request:
[0099] Used to update an existing data record. You send a request containing the updated data to the URL of a specific resource.
[0100] For example, to update user information, you can send a PUT request to / users / 123, where 123 is the user ID and the updated user information is included in the request body.
[0101] The advantage is that the update operation is clearly indicated. The disadvantage is that if the update operation is frequent, it may generate more network overhead.
[0102] DELETE request:
[0103] Used to delete data records. Send a DELETE request to the URL of a specific resource to delete the corresponding record.
[0104] For example, to delete a user, you can send a DELETE request to / users / 123.
[0105] The advantage is that the operation is clear. The disadvantage is that it needs to be used with caution to prevent accidental deletion of data.
[0106] 2. RPC (Remote Procedure Call):
[0107] Requests are made through a specific RPC framework (such as gRPC, Thrift).
[0108] The client and server define the interface and data structure, and then communicate through the RPC framework.
[0109] The advantages are high efficiency, support for multiple programming languages, and the ability to transfer complex data types. The disadvantages are that a specific framework needs to be introduced, and the learning cost is relatively high.
[0110] 3. Database-specific protocols:
[0111] Some databases may have their own specific protocols for communication between clients and the database.
[0112] For example, MySQL has its own client / server protocol.
[0113] The advantage is that it is optimized for a specific database and may have better performance. The disadvantage is that it can usually only be used for that specific database and lacks versatility.
[0114] At least one of a request method and data processing logic, and at least one of connection information, query statements, and result parsing logic required to configure a third-party database;
[0115] The data processing logic of a third-party database usually includes the following main aspects:
[0116] 1. Data Storage:
[0117] Data structure design:
[0118] Third-party databases will design appropriate data structures based on different data types and business requirements. For example, for a relational database, you may design a table structure and define field types, lengths, constraints, etc. For a non-relational database, you may use different data models such as documents, key-value pairs, and graphs.
[0119] Reasonable data structure design can improve data storage efficiency and query performance.
[0120] Data writing:
[0121] When new data needs to be stored, the database will write the data to the corresponding storage location according to the established data structure. This may involve serialization of data (converting data into a format suitable for storage) and updating of indexes.
[0122] For high-concurrency write operations, the database may use transaction processing, locking mechanisms and other technologies to ensure data consistency and integrity.
[0123] 2. Data query:
[0124] Parsing query statement:
[0125] When a query request is received, the database will first parse the query statement to understand the user's query intent, including identifying the query table, field, condition, sort, and other information.
[0126] Different types of databases may use different query languages, such as SQL for relational databases, while NoSQL databases may have their own specific query syntax.
[0127] Index lookup:
[0128] In order to improve query performance, databases usually create indexes. During the query process, the database will quickly locate data that meets the conditions based on the index.
[0129] There are many types of indexes, such as B-tree index and hash index. Different indexes are suitable for different query scenarios.
[0130] Data Retrieval:
[0131] Based on the query conditions and indexes, the database retrieves the data that meets the requirements from the storage. If the amount of data is large, paging, blocking and other technologies may be used to gradually return the results to avoid memory overflow.
[0132] 3. Data update:
[0133] Data modification:
[0134] When data needs to be updated, the database will find the corresponding data record according to the update request and perform the modification operation. This may involve locking the data to prevent data inconsistency caused by concurrent updates.
[0135] For some update operations, the database may use mechanisms such as optimistic locking or pessimistic locking to ensure data integrity.
[0136] Index Update:
[0137] After the data is updated, the related indexes also need to be updated to ensure the accuracy and efficiency of the query.
[0138] 4. Data Deletion:
[0139] Data location:
[0140] After receiving the deletion request, the database will find the data record to be deleted according to the deletion conditions.
[0141] Likewise, some verification operations may be performed to prevent accidental deletion.
[0142] Data cleaning:
[0143] After deleting data records, the database will clean up the corresponding storage space and update data structures such as indexes.
[0144] 5. Data security and rights management:
[0145] Access Control:
[0146] Third-party databases control access to data through user authentication and authorization mechanisms. Only authorized users can perform specific operations, such as querying, updating, and deleting data.
[0147] This may involve setting up user roles, permission levels, etc.
[0148] Data Encryption:
[0149] To protect data security, the database may encrypt the stored data. When querying and updating data, corresponding decryption operations are required.
[0150] The encryption method can be symmetric or asymmetric, depending on the security requirements of the database.
[0151] Backup and restore:
[0152] To prevent data loss, the database is backed up regularly. In the event of data corruption or loss, it can be restored from the backup.
[0153] The backup strategy can be full backup, incremental backup, etc. The recovery process may need to consider the consistency and integrity of the data.
[0154] The connection information required by third-party databases typically requires the following information:
[0155] 1. Basic connection information:
[0156] Database type: Make it clear whether the database you are connecting to is a relational database (such as MySQL, PostgreSQL, Oracle, etc.) or a non-relational database (such as MongoDB, Redis, Cassandra, etc.). Different types of databases have different connection methods and required parameters.
[0157] Host: The IP address or domain name of the database server. This is key information for locating the server when the client connects to the database. For example, for a locally installed database, it may be "localhost"; for a database on a remote server, it is a specific IP address or a resolvable domain name.
[0158] Port number: Each database usually listens for connection requests on a specific port. Different databases have different default port numbers, for example, the default port for MySQL is 3306, PostgreSQL is 5432, and MongoDB is 27017. If the database server uses a non-default port, you need to specify the port number explicitly.
[0159] 2. Authentication information:
[0160] Username: The user name used to log in to the database. The database administrator will assign different permissions to different users to control access and operations to the database. For example, in an enterprise-level database, there may be users with different roles such as administrator users and ordinary users, and each user has his or her own user name.
[0161] Password: The password corresponding to the user name is used to verify the user's identity. The password should be kept properly to ensure the security of the database. When connecting to the database, the client usually encrypts the password to prevent the password from being stolen.
[0162] 3. Other information that may be needed:
[0163] Database Name: If it is a relational database, you usually need to specify the specific database name to connect to. There can be multiple databases on a database server, and the client needs to clearly connect to which database to operate. For example, there may be multiple databases such as "db1" and "db2" on a MySQL server.
[0164] SSL configuration: For some scenarios with high security requirements, you may need to configure an SSL (Secure Sockets Layer) connection to encrypt data transmission. This may require providing relevant information such as SSL certificates and keys. For example, when connecting to a PostgreSQL database that supports SSL, you may need to specify the SSL mode (such as "require", "verify-ca", "verify-full", etc.) and the path to the certificate file.
[0165] Connection Timeout: Set the timeout for connecting to the database to prevent long waiting times without response during the connection process. If the connection cannot be established within the specified time, the client can take appropriate error handling measures. For example, you can set the connection timeout to 30 seconds. If you cannot connect to the database within 30 seconds, the user will be prompted that the connection failed.
[0166] Maximum Connections: Some database connection pools or clients may need to specify the maximum number of connections to control the use of database resources. If the number of connections exceeds the maximum limit, new connection requests may be rejected or wait for existing connections to be released. For example, in a high-concurrency application, the maximum number of connections may need to be reasonably set based on server performance and expected concurrency.
[0167] The query statements for third-party databases vary depending on the database type. The following uses the common relational database MySQL and the non-relational database MongoDB as examples.
[0168] 1. MySQL query statement:
[0169] Basic query:
[0170] Query all columns: SELECT * FROM table_name;, where table_name is the name of the table to be queried. This will return data for all rows and all columns in the table.
[0171] Query specific columns: SELECT column1, column2 FROM table_name; specify the column name to be queried, and multiple columns can be queried.
[0172] Conditional query:
[0173] Use the WHERE clause to specify the query condition: SELECT * FROM table_name WHERE condition;, for example, SELECT * FROM users WHERE age>18; to query users who are older than 18 years old.
[0174] You can use logical operators (such as AND, OR, NOT) to combine multiple conditions: SELECT * FROM table_name WHERE condition1 AND condition2;.
[0175] Sorting query:
[0176] Use the ORDER BY clause to sort the query results: SELECT * FROM table_name ORDER BY column_name ASC / DESC;, where column_name is the name of the column to be sorted, ASC indicates ascending order, and DESC indicates descending order. For example, SELECT * FROM users ORDER BY age DESC; sorts users in descending order by age.
[0177] Pagination query:
[0178] Use LIMIT and OFFSET to implement paging: SELECT * FROM table_name LIMIT limit_valueOFFSET offset_value;, where limit_value is the number of records displayed per page, and offset_value is the offset, indicating the row from which to start the query. For example, SELECT * FROM users LIMIT 10OFFSET 20; queries records from 21 to 30.
[0179] Aggregation query:
[0180] Use aggregate functions (such as COUNT, SUM, AVG, MAX, MIN) to perform statistics: SELECT COUNT(*) FROM table_name; query the total number of records in the table. SELECT AVG(age) FROM users; query the average age of users.
[0181] 2. MongoDB query statement:
[0182] Basic query:
[0183] Query all documents: db.collection.find();, where collection is the name of the collection to be queried. This will return all documents in the collection.
[0184] Query specific fields: db.collection.find({},{field1:1,field2:1});, specify the field to be returned, 1 means return the field, 0 means do not return the field. For example, db.users.find({},{name:1,age:1});, query the user's name and age fields.
[0185] Conditional query:
[0186] Use query operators to specify query conditions: db.collection.find({condition});, for example, db.users.find({age:{$gt:18}}); to query users older than 18. Common query operators include $gt (greater than), $lt (less than), $gte (greater than or equal to), $lte (less than or equal to), $in (in range), $nin (not in range), etc.
[0187] Sorting query:
[0188] Use the sort() method to sort the query results: db.collection.find().sort({column_name:1 / -1});, where column_name is the name of the field to be sorted, 1 indicates ascending order, and -1 indicates descending order. For example, db.users.find().sort({age:-1}); sorts users in descending order by age.
[0189] Pagination query:
[0190] Use the skip() and limit() methods to implement paging: db.collection.find().skip(offset_value).limit(limit_value);, where offset_value is the offset, indicating the row to start the query from, and limit_value is the number of records displayed per page. For example, db.users.find().skip(20).limit(10); queries the 21st to 30th records.
[0191] Aggregation query:
[0192] Use the aggregation pipeline to perform complex aggregation operations: db.collection.aggregate(pipeline);, where pipeline is an array containing multiple aggregation stages. For example, db.users.aggregate([{$group:{_id:null,totalAge:{$sum:"$age"}}}]); calculates the total age of users.
[0193] In short, different third-party databases have different query syntax and characteristics. When using them, you need to refer to the corresponding database documentation for accurate query operations.
[0194] The result parsing logic of third-party databases usually involves the following aspects:
[0195] 1. Determine the result data structure:
[0196] Relational database:
[0197] If it is a relational database such as MySQL, Oracle, etc., the query results are usually presented in a table format. Each row represents a record and each column represents a field.
[0198] When parsing, you need to clarify the name, data type, and meaning of each field. For example, the result of a query for employee information may contain fields such as "employee number", "name", "department", and "salary".
[0199] Non-relational databases:
[0200] For non-relational databases such as MongoDB, the result may be a collection of documents. Each document can have a different structure, depending on the data stored.
[0201] When parsing, you need to extract the required information based on the specific document structure. For example, a MongoDB collection that stores user comments may contain fields such as "user ID", "comment content", and "comment time".
[0202] 2. Extract key information:
[0203] Determine the key information to be extracted based on the requirements. For example, if the purpose of the query is to obtain the sales quantity of a specific product, then you need to extract the field values related to the product sales quantity from the results.
[0204] For complex query results, you may need to perform multi-layer nested information extraction. For example, to query a document containing multiple sub-objects, you need to first find the corresponding sub-objects and then extract the specific information from them.
[0205] 3. Data type conversion:
[0206] The data type in the database may not be exactly the same as the data type required by the application, so data type conversion is required.
[0207] For example, a date and time field in a database may be stored as a string and needs to be converted into a date object for processing in an application.
[0208] Numeric fields may need to be converted from a specific format in the database to a numeric type that the application understands.
[0209] For special data types such as Boolean values and enumeration types, corresponding conversion is also required to ensure that the application can correctly process the result data.
[0210] 4. Error handling:
[0211] Check whether the query result contains error information. If the database returns an error code or error message, you need to perform corresponding error handling.
[0212] For example, if a query fails due to insufficient permissions, the application needs to prompt the user and take appropriate action, such as requesting higher permissions or adjusting the query criteria.
[0213] It is also important to handle empty results. If a query does not return any results, the application needs to decide how to handle it based on the specific situation, which may be to display a prompt message, take the default behavior, or perform other operations.
[0214] 5. Result set processing:
[0215] If the query result is a result set containing multiple records, it needs to be traversed and processed according to the needs of the application.
[0216] You can use a loop structure to process each record in the result set one by one, extract the required information and perform further operations.
[0217] For large result sets, you may want to consider paging or streaming to avoid excessive memory usage.
[0218] If statistical analysis or aggregation operations are required on the result set, corresponding calculations and processing need to be performed according to specific requirements, for example, calculating the average value, sum, maximum value, minimum value, etc. in the result set.
[0219] This embodiment can achieve the purpose of data interaction with various third-party databases through JavaScript scripts by configuring the above-mentioned various parameters, and the above-mentioned configuration is decoupled from the main project of the software and will not bring burden to the development of the main project.
[0220] Based on the above technical solutions, optionally, executing the target JavaScript script in the Nashorn engine to interact with a third-party database through the target JavaScript script includes:
[0221] The target JavaScript script is executed in the Nashorn engine to directly operate the third-party database through the JavaScript code of the target JavaScript script to interact with the third-party database.
[0222] In this solution, during the use of the Nashorn engine, the Nashorn engine can be repackaged so that during the JavaScript script call process, the JavaScript code of the JavaScript script can be better used to operate the third-party database and complete data interaction.
[0223] Deep secondary packaging and functional expansion of the Nashorn engine: This project creatively introduced the Nashorn engine and performed deep secondary packaging. This move not only retained the basic advantages of Nashorn as a high-performance JavaScript engine, but also gave JavaScript code unprecedented capabilities through customized development. Specifically, the system successfully achieved functional breakthroughs in the following aspects:
[0224] Database connection capability, encapsulates JDBC connection logic, and provides database operation interface in JavaScript.
[0225] Through such a setting, this solution uses a secondary encapsulated system to allow JavaScript code to directly perform database operations without the need for cumbersome Java code bridging, which greatly simplifies the database interaction process and improves development efficiency.
[0226] Based on the above technical solutions, optionally, executing the target JavaScript script in the Nashorn engine to interact with a third-party database through the target JavaScript script includes:
[0227] The target JavaScript script is executed in the Nashorn engine, and the file reading and writing interface provided by the Nashorn engine is used to directly read and write files when the target JavaScript script interacts with a third-party database, and the image loading and processing interface provided by the Nashorn engine is used to directly load and process images when the target JavaScript script interacts with the third-party database.
[0228] Among them, file and image processing capabilities: using Java's file IO and image processing libraries, providing file reading and writing and image processing APIs in JavaScript, expanding JavaScript's capabilities in file and image processing, and allowing file reading and writing, image loading and processing and other operations to be performed directly in JavaScript code, providing more possibilities for data interaction between the Web front-end and back-end.
[0229] Through such a setting, this solution can realize the reading and writing of files and the loading and processing of pictures, and can provide users with more powerful business system services, improve the user experience, and meet the user's growing usage needs.
[0230] Based on the above technical solutions, optionally, the Nashorn engine uses the engine.eval() method to execute the JavaScript code of the JavaScript script;
[0231] The Nashorn engine calls functions in JavaScript scripts through the Invocable interface.
[0232] Among them, Java objects are exposed to JavaScript: Java classes are accessed through Java's ScriptableObject interface or directly in the script using Java.type / Java.byName.
[0233] Among them, JavaScript function call: use engine.eval() to execute JavaScript code, and call the function in JavaScript through the Invocable interface.
[0234] Through such a setting, this solution can achieve better use of JavaScript and call existing JavaScript functions, thereby improving the convenience of using JavaScript scripts in the Nashorn engine, reducing the burden of code writing, and achieving the purpose of simplicity and ease of use.
[0235] In addition, during the repackaging of the Nashorn engine, the following capabilities were also improved:
[0236] Two-way data transmission capability: The system supports seamless transmission of data from the Java business system to the JavaScript code. At the same time, data processed by JavaScript can also be easily transmitted back to the business system, realizing the free flow of data between Java and JavaScript.
[0237] JSON and date processing capabilities: Through the built-in efficient JSON parsing and generation library, as well as date processing tools, the system enables JavaScript code to easily process complex JSON data structures and dates and times, meeting data processing requirements in complex business scenarios.
[0238] Through secondary encapsulation, the present invention successfully integrates database connection capabilities into JavaScript (JS) code. Specifically, the encapsulation layer provides mechanisms such as database connection pool management, SQL statement execution, and result set mapping, so that JS code can directly execute database operations without relying on Java code for bridging.
[0239] Based on the above technical solutions, optionally, during the operation of the business system, if it is identified that the business system is running to a preset cut-off point, before the target JavaScript script corresponding to the current preset cut-off point is called by the Nashorn engine, the following is also included:
[0240] The JavaScript code of the JavaScript script is configured through the pointcut configurator, and the business method associated with the JavaScript code is defined to control the JavaScript code to be executed in the business method, or before the business method, or after the business method.
[0241] In this solution, the AOP (point-cut) configurator is also innovatively applied. In order to further improve the flexibility and configurability of the system, this project innovatively developed the AOP (aspect-oriented programming) configurator. This configurator has the following significant advantages:
[0242] Flexible JS code configuration: supports users to freely configure which JavaScript codes should be executed in which business methods according to business needs, and whether these codes should be executed before or after the business method is executed.
[0243] Through such settings, this solution can adopt a flexible configuration method, allowing the system to easily cope with various complex business scenarios.
[0244] Based on the above technical solutions, optionally, during the operation of the business system, if it is identified that the business system is running to a preset cut-off point, before the target JavaScript script corresponding to the current preset cut-off point is called by the Nashorn engine, the following is also included:
[0245] The newly added JavaScript code of the JavaScript script is configured through the cut-off point configurator to update the JavaScript script.
[0246] Among them, as business needs continue to change, the AOP configurator can easily adapt to new business needs and integrate and execute new JavaScript scripts through simple configuration, thus ensuring the scalability of the system.
[0247] Through such a setting, this solution can enhance the scalability of the system and improve the ease of interaction with third-party databases through JavaScript scripts.
[0248] The AOP configurator strategy provided in this embodiment can improve development efficiency and maintainability. By separating business logic from the execution logic of JavaScript scripts, the AOP configurator allows developers to focus on the implementation of business logic without having to worry about the timing and method of calling JavaScript scripts. This not only improves development efficiency, but also reduces the maintenance cost of the system in the later stage.
[0249] Figure 2 is a schematic diagram of the JavaScript script configuration process provided in Example 1 of the present application, Figure 3 is a flow chart of the interaction with a third-party database through a JavaScript script provided in the first embodiment of the present application, such as Figure 2 Shown and Figure 3 As shown, the implementation process of this solution mainly includes the following steps:
[0250] Step 1, JavaScript script writing: First, write all logic related to third-party interface calls and database reading into JavaScript scripts. These scripts contain the parameters, request methods, data processing logic, etc. required to call third-party interfaces, as well as the connection information, query statements, result parsing logic, etc. required to read third-party databases.
[0251] Step 2: Nashorn engine integration: Integrate the Nashorn engine into the software system to dynamically execute JavaScript scripts. Nashorn is a high-performance JavaScript engine on the Java platform that can directly run JavaScript code and interoperate with Java code.
[0252] Step 3, AOP point definition: Use AOP technology to define point cuts in the software system. These point cuts correspond to where third-party data needs to be called. When the program executes to these point cuts, AOP notifications are automatically triggered and the corresponding JavaScript scripts are executed.
[0253] Step 4, script execution and result processing: In the AOP notification, the corresponding JavaScript script is loaded and executed through the Nashorn engine. After the script is executed, the result is returned to the main program, and the main program performs subsequent business processing based on the returned result.
[0254] Step 5, decoupling and expansion: Through the above method, the main project and third-party data are decoupled. When the third-party interface or database changes, only the corresponding JavaScript script needs to be modified without making a lot of changes to the main project. In addition, due to the flexibility of JavaScript scripts, new interface calls or database reading logic can be easily added to achieve rapid expansion of the system.
[0255] The technical solution provided by the present invention can reduce intrusiveness. By separating the JavaScript script from the main project, the intrusiveness of third-party data interaction on the main project is reduced, and the maintainability of the project is improved. Flexibility is improved. By utilizing the flexibility of JavaScript scripts, the third-party data interaction logic can be easily modified and expanded to meet changing business needs. Portability is enhanced. Due to the cross-platform nature of JavaScript scripts, the technical solution of the present invention can be easily ported to different software systems to achieve cross-platform data interaction. Development efficiency is improved. By dynamically executing JavaScript scripts, a large amount of redundant code is avoided in the main project, thereby improving development efficiency.
[0256] The operating principle of the Nashorn engine is as follows:
[0257] Nashorn is a high-performance JavaScript engine on the Java platform that implements the ECMAScript 5.1 specification and provides the ability to interact with Java code. The present invention uses the Nashorn engine as the execution environment of JavaScript code, and interoperates with Java code through the API it provides, thereby realizing the function of dynamically executing JavaScript scripts. The operating principle of the Nashorn engine includes steps such as lexical analysis, syntax analysis, intermediate code generation, optimization, and bytecode generation, which together ensure the efficient execution of JavaScript code.
[0258] Example:
[0259]
[0260] Compatibility issues with JDK 15 and above We use GraalVM, which provides an example JavaScript engine that can be embedded in Java applications:
[0261]
[0262] AOP (Aspect-Oriented Programming) technology:
[0263] AOP is a programming paradigm that implements cross-cutting concerns for program execution processes by defining pointcuts and advices. In the present invention, AOP technology is used to define pointcuts in the software system, which correspond to places where third-party data needs to be called. When the program executes to these pointcuts, AOP notifications are automatically triggered, and then the corresponding JavaScript scripts are executed. The theoretical basis of AOP technology includes design patterns such as proxy mode and decorator mode, as well as the principle of separation of cross-cutting concerns and business logic.
[0264] JavaScript and Java interoperability:
[0265] The present invention relies on the interoperability between JavaScript and Java. The Nashorn engine provides a rich API, which enables JavaScript code to access Java objects, call Java methods, and process Java-type data. At the same time, Java code can also interact with JavaScript code through the interface provided by the Nashorn engine. This interoperability is one of the keys to the implementation of the present invention.
[0266] Security mechanisms for dynamic code execution:
[0267] When executing dynamic code, security is an important consideration. The present invention may rely on the security mechanism of the Java platform (such as sandbox mechanism, class loader isolation, etc.) to ensure that the dynamically executed JavaScript code will not have an adverse impact on the main system. At the same time, it is also necessary to consider potential risks such as code injection and long execution time, and take corresponding security measures to prevent them.
[0268] In summary, the theoretical basis on which the present invention relies mainly includes the operating principle of the Nashorn engine, AOP technology, the interoperability of JavaScript and Java, and the security mechanism of dynamic code execution. These theoretical bases together constitute the technical foundation of the present invention, ensuring that it can efficiently and safely realize the function of third-party data interaction.
[0269] This solution proposes to dynamically run JavaScript code and utilizes the Nashorn engine to achieve the ability to dynamically execute JavaScript code on the Java platform. This technological breakthrough allows the logic of third-party data interaction to exist in the form of scripts rather than being directly embedded in the code of the main project, thereby reducing the intrusion into the main project.
[0270] The application of AOP (Aspect Oriented Programming) uses AOP technology to define cut-off points in the software system. These cut-off points correspond to the places where third-party data needs to be called. When the program executes to these cut-off points, the AOP notification will be automatically triggered, and then the corresponding JavaScript script will be executed. This mechanism not only improves the reusability of the code, but also makes the logic of third-party data interaction more flexible and easy to manage.
[0271] The present invention decouples JavaScript scripts from the main project by writing the logic of third-party data interaction into the JavaScript script and interacting with the main project through the Nashorn engine and AOP technology. This decoupling method allows only the corresponding JavaScript script to be modified when the third-party interface or database changes, without making a lot of modifications to the main project, thereby improving the maintainability and scalability of the project.
[0272] A large number of technical improvements are proposed for the above solution, and some of the technical highlights are briefly summarized as follows:
[0273] 1. Secondary packaging technology implementation method of Nashorn engine:
[0274] Granting database connection capabilities:
[0275] Through secondary encapsulation, the present invention successfully integrates database connection capabilities into JavaScript (JS) code. Specifically, the encapsulation layer provides mechanisms such as database connection pool management, SQL statement execution, and result set mapping, so that JS code can directly execute database operations without relying on Java code for bridging.
[0276] Data transmission and return mechanism:
[0277] The system implements a two-way data transmission mechanism between JS code and Java business system. On the one hand, the system can pass the data in the Java business system to the JS code in a specific format (such as JSON, XML, etc.); on the other hand, the data processed by the JS code can also be transmitted back to the Java business system through a predefined interface, realizing seamless data connection.
[0278] Expansion of data processing capabilities:
[0279] During the secondary packaging process, the system adds the ability to process JSON data, dates, and file images to the JS code. Specifically, the packaging layer has built-in efficient JSON parsing / generation libraries, date processing tools, and file IO and image processing APIs, allowing the JS code to easily process these complex data types and meet the diverse needs of business scenarios.
[0280] 2. Technical implementation of AOP (pointcut) configurator:
[0281] Flexible configuration strategies:
[0282] The AOP configurator of the present invention supports highly flexible configuration strategies, allowing users to specify which JS codes are executed in which Java business methods, and whether these codes are executed before or after the business methods are executed. This configuration method greatly improves the flexibility and customizability of the system, allowing developers to quickly adjust the execution logic of the script according to actual needs.
[0283] Dynamic execution control:
[0284] The AOP configurator uses dynamic proxy and other technical means to achieve precise control of the execution timing of JS code. During the execution of business methods, the configurator can automatically trigger the execution of corresponding JS code according to preset rules to ensure that the code works at the right time. This dynamic execution control mechanism improves the response speed and stability of the system.
[0285] Seamless integration and expansion:
[0286] The AOP configurator is seamlessly integrated with the Java business system, and the JS code can be inserted and executed without large-scale modification of the original business code. At the same time, the configurator also provides a rich extension interface and plug-in mechanism, allowing developers to add new functional modules or customize execution logic according to business needs, further improving the scalability and maintainability of the system.
[0287] In summary, with the two innovative technologies of the secondary encapsulation technology of the Nashorn engine and the technical implementation method of the AOP configurator, the present invention not only improves the efficiency and flexibility of using JavaScript in Java applications, but also provides a new solution for the interoperability between Java and JavaScript.
[0288] Embodiment 2
[0289] Figure 4 Schematic diagram of the structure of the interactive device between the business system and the third-party database provided in the second embodiment of the present application. Figure 4 As shown, the device comprises:
[0290] The user request receiving module 410 is used to receive a user request sent by a user in the business system;
[0291] The calling module 420 is used to call the target JavaScript script corresponding to the current preset cut-off point through the Nashorn engine if it is identified that the business system runs to the preset cut-off point during the operation of the business system;
[0292] An execution module 430, configured to execute the target JavaScript script in the Nashorn engine, so as to interact with a third-party database through the target JavaScript script;
[0293] The business response module 440 is used to perform a business response to the user request according to the interactive data returned by the target JavaScript script of the preset cut-off point.
[0294] This device can execute the interaction method between the business system and the third-party database provided in the above embodiments, and has corresponding functional units and beneficial effects, which will not be described in detail here.
[0295] Embodiment 3
[0296] The embodiment of the present application further provides a storage medium including computer executable instructions, wherein the computer executable instructions are used to execute a method for interacting between a business system and a third-party database when executed by a computer processor, the method comprising:
[0297] Receive user requests sent by users in the business system;
[0298] During the operation of the business system, if it is identified that the business system is running to a preset cut-off point, the target JavaScript script corresponding to the current preset cut-off point is called through the Nashorn engine;
[0299] Executing the target JavaScript script in the Nashorn engine to interact with a third-party database through the target JavaScript script;
[0300] A business response is made to the user request according to the interactive data returned by the target JavaScript script of the preset cut-off point.
[0301] Storage medium - any of various types of memory electronic devices or storage electronic devices. The term "storage medium" is intended to include: installation media, such as CD-ROM, floppy disk or tape device; computer system memory or random access memory, such as DRAM, DDR RAM, SRAM, EDO RAM, Rambus RAM, etc.; non-volatile memory, such as flash memory, magnetic media (such as hard disk or optical storage); registers or other similar types of memory elements, etc. Storage media may also include other types of memory or combinations thereof. In addition, the storage medium may be located in the computer system in which the program is executed, or may be located in a different second computer system, which is connected to the computer system via a network (such as the Internet). The second computer system can provide program instructions to the computer for execution. The term "storage medium" may include two or more storage media that may reside in different locations (for example, in different computer systems connected by a network). The storage medium may store program instructions (for example, embodied as a computer program) that can be executed by one or more processors.
[0302] Of course, the storage medium containing computer executable instructions provided in an embodiment of the present application is not limited to the interactive operations between the business system and the third-party database as described above, but can also execute related operations in the interactive method between the business system and the third-party database provided in any embodiment of the present application.
[0303] Embodiment 4
[0304] The embodiment of the present application further provides an interactive system between a business system and a third-party database, wherein the interactive system between the business system and the third-party database is used to execute an interactive method between the business system and the third-party database, the method comprising:
[0305] Receive user requests sent by users in the business system;
[0306] During the operation of the business system, if it is identified that the business system is running to a preset cut-off point, the target JavaScript script corresponding to the current preset cut-off point is called through the Nashorn engine;
[0307] Executing the target JavaScript script in the Nashorn engine to interact with a third-party database through the target JavaScript script;
[0308] A business response is made to the user request according to the interactive data returned by the target JavaScript script of the preset cut-off point.
[0309] The technical solution provided in this embodiment receives a user request issued by a user in a business system; during the operation of the business system, if it is identified that the business system is running to a preset cut-off point, the target JavaScript script corresponding to the current preset cut-off point is called through the Nashorn engine; the target JavaScript script is executed in the Nashorn engine to interact with a third-party database through the target JavaScript script; and a business response is made to the user request based on the interaction data returned by the target JavaScript script at the preset cut-off point. By adopting this solution, the JavaScript script can be separated from the main project, thereby reducing the intrusiveness of the third-party data interaction to the main project and improving the maintainability of the project; improving flexibility, using the flexibility of the JavaScript script, the third-party data interaction logic can be easily modified and expanded to meet the ever-changing business needs; enhancing portability, due to the cross-platform nature of the JavaScript script, the technical solution of the present invention can be easily ported to different software systems to achieve cross-platform data interaction; improving development efficiency, by dynamically executing JavaScript scripts, avoiding the writing of a large amount of redundant code in the main project, thereby improving development efficiency.
[0310] Embodiment 5
[0311] An embodiment of the present application provides an electronic device. Figure 5 Schematic diagram of the structure of an electronic device provided in Embodiment 5 of the present application. Figure 5 As shown, this embodiment provides an electronic device 500, which includes: one or more processors 520; a storage device 510, which is used to store one or more programs. When the one or more programs are run by the one or more processors 520, the one or more processors 520 implement the interaction method between the business system and the third-party database provided in the embodiment of the present application. The method includes:
[0312] Receive user requests sent by users in the business system;
[0313] During the operation of the business system, if it is identified that the business system is running to a preset cut-off point, the target JavaScript script corresponding to the current preset cut-off point is called through the Nashorn engine;
[0314] Executing the target JavaScript script in the Nashorn engine to interact with a third-party database through the target JavaScript script;
[0315] A business response is made to the user request according to the interactive data returned by the target JavaScript script of the preset cut-off point.
[0316] Figure 5 The electronic device 500 shown is merely an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.
[0317] like Figure 5 As shown, the electronic device 500 includes a processor 520, a storage device 510, an input device 530, and an output device 540; the number of the processor 520 in the electronic device can be one or more. Figure 5 A processor 520 is taken as an example; the processor 520, the storage device 510, the input device 530 and the output device 540 in the electronic device can be connected via a bus or other means. Figure 5 The connection via bus 550 is taken as an example.
[0318] The storage device 510, as a computer-readable storage medium, can be used to store software programs, computer-executable programs and module units, such as program instructions corresponding to the interaction method between the business system and the third-party database in the embodiment of the present application.
[0319] The storage device 510 may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system and at least one application required for a function; the data storage area may store data created according to the use of the terminal, etc. In addition, the storage device 510 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other non-volatile solid-state storage device. In some instances, the storage device 510 may further include a memory remotely arranged relative to the processor 520, and these remote memories may be connected via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0320] The input device 530 may be used to receive input numbers, character information or voice information, and generate key signal input related to user settings and function control of the electronic device. The output device 540 may include electronic devices such as a display screen and a speaker.
[0321] The electronic device provided in this embodiment receives a user request issued by a user in a business system; during the operation of the business system, if it is identified that the business system is running to a preset cut-off point, the target JavaScript script corresponding to the current preset cut-off point is called through the Nashorn engine; the target JavaScript script is executed in the Nashorn engine to interact with a third-party database through the target JavaScript script; and a business response is made to the user request according to the interaction data returned by the target JavaScript script at the preset cut-off point. By adopting this solution, the intrusiveness of third-party data interaction to the main project can be reduced by separating the JavaScript script from the main project, and the maintainability of the project can be improved; the flexibility can be improved, and the flexibility of the JavaScript script can be used to conveniently modify and expand the third-party data interaction logic to meet the ever-changing business needs; the portability is enhanced, and due to the cross-platform nature of the JavaScript script, the technical solution of the present invention can be easily ported to different software systems to achieve cross-platform data interaction; the development efficiency is improved, and by dynamically executing the JavaScript script, a large amount of redundant code can be avoided in the main project, thereby improving the development efficiency.
[0322] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented in one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that include computer-usable program code.
[0323] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1A device that provides the functions specified in a block or multiple blocks.
[0324] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0325] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0326] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.
[0327] The memory may include non-permanent storage in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. The memory is an example of a computer-readable medium.
[0328] Computer readable media include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. Information can be computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.
[0329] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.
[0330] The above is only an embodiment of the present application and is not intended to limit the present application. For those skilled in the art, the present application may have various changes and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included in the scope of the claims of the present application.
Claims
1. A method for interaction between a business system and a third-party database, characterized in that: The method comprises: Receive user requests sent by users in the business system; During the operation of the business system, if it is identified that the business system is running to a preset cut-off point, the target JavaScript script corresponding to the current preset cut-off point is called through the Nashorn engine; Executing the target JavaScript script in the Nashorn engine to interact with a third-party database through the target JavaScript script; A business response is made to the user request according to the interactive data returned by the target JavaScript script of the preset cut-off point.
2. The method according to claim 1, characterized in that Before receiving a user request sent by a user in a business system, it also includes: In response to the configuration operation of the JavaScript script, the JavaScript script is configured; wherein the configuration includes at least one of the interface parameters, request mode and data processing logic required for configuring the third-party database interface, and at least one of the connection information, query statement and result parsing logic required for configuring the third-party database; After the JavaScript script configuration is completed, the JavaScript script is imported into the business system so that the JavaScript script is called when the business system runs to a preset cut-off point and issues a call instruction.
3. The method according to claim 1, characterized in that Executing the target JavaScript script in the Nashorn engine to interact with a third-party database through the target JavaScript script includes: The target JavaScript script is executed in the Nashorn engine to directly operate the third-party database through the JavaScript code of the target JavaScript script to interact with the third-party database.
4. The method according to claim 1, characterized in that: Executing the target JavaScript script in the Nashorn engine to interact with a third-party database through the target JavaScript script includes: The target JavaScript script is executed in the Nashorn engine, and the file reading and writing interface provided by the Nashorn engine is used to directly read and write files when the target JavaScript script interacts with a third-party database, and the image loading and processing interface provided by the Nashorn engine is used to directly load and process images when the target JavaScript script interacts with the third-party database.
5. The method according to claim 3 or 4, characterized in that: The Nashorn engine uses the engine.eval() method to execute the JavaScript code of the JavaScript script; The Nashorn engine calls functions in JavaScript scripts through the Invocable interface.
6. The method according to claim 1, characterized in that During the operation of the business system, if it is identified that the business system is running to a preset cut-off point, before the target JavaScript script corresponding to the current preset cut-off point is called by the Nashorn engine, the following is also included: The JavaScript code of the JavaScript script is configured through the pointcut configurator, and the business method associated with the JavaScript code is defined to control the JavaScript code to be executed in the business method, or before the business method, or after the business method.
7. The method according to claim 1, characterized in that During the operation of the business system, if it is identified that the business system is running to a preset cut-off point, before the target JavaScript script corresponding to the current preset cut-off point is called by the Nashorn engine, the following is also included: The newly added JavaScript code of the JavaScript script is configured through the cut-off point configurator to update the JavaScript script.
8. An interactive device between a business system and a third-party database, characterized in that: The device comprises: A user request receiving module is used to receive a user request sent by a user in the business system; The calling module is used to call the target JavaScript script corresponding to the current preset cut-off point through the Nashorn engine if the business system is identified to be running to the preset cut-off point during the operation of the business system; An execution module, used for executing the target JavaScript script in the Nashorn engine, so as to interact with a third-party database through the target JavaScript script; The business response module is used to perform a business response to the user request according to the interactive data returned by the target JavaScript script of the preset cut-off point.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method for interaction between a business system and a third-party database as described in any one of claims 1 to 7 is implemented.
10. An interactive system between a business system and a third-party database, characterized in that: The interaction system between the business system and the third-party database is used to execute the interaction method between the business system and the third-party database as described in any one of claims 1-7.
Citation Information
Cited By
Micro-service decoupling method and device and storage medium
CN120233999A
Data transmission method and device, storage medium and computer program product
CN120343080A