Improved architecture, implemented dynamic data sources, and reduced java Maintenance

Source: Internet
Author: User
Tags database sharding

How can I complete development without writing java code?

Page changes are a headache for most products and projects. Every time a small function is launched, new customers will need to carry out custom transformation and continuous development and maintenance. On the one hand, you need to modify the page for each development, on the other hand, you need to modify the server code and then deploy it. With the help of dynamic data sources, you can directly develop functions without developing backend applications.

When developing a new function, you only need to define the required data format and obtaining method. For example, if you upload an SQL statement using xml, the system automatically extracts data and converts it to a common format based on the SQL statement. During the development process, the java Development Section in the background only writes the SQL statements and uploads them. In this way, the foreground can dynamically read and execute the SQL statements using a servlet and return the results to the front end in json format, for future development, you only need the front-end to implement the ajax page.

The complete business process is as follows:

1. the user operates on the front-end and needs to read economic books.

2. The front-end js determines what the operation is, and then sends the ajax request to: http://services.guzz.org/commonServlet? Id = f2354239sfasasfasf6 & catId = 47 & keyword = jingji .....

3. the server side has something similar to dispatcher-servlet (Our commonServlet here) that intercepts the request. According to the id, the SQL file named f2354239sfasasfasf6 needs to be executed to load the data. The parameter is required during execution: catId = 47 and keyword = jingji

4. commonServlet reads f2354239sfASASFASfasf6 from the file system. xml file (this file is in a hidden directory and cannot be directly obtained from the browser; the cluster environment will be stored in centralized storage), parsing SQL and object ORM ing ORM.

5. commonServlet opens the database connection, constructs a query statement based on SQL, and passes all the parameters passed in the first step to the query statement for query.

6. commonServlet converts the queried ResultSet into a java class based on the ORM, converts it to json, and returns to the foreground.

7. The front-end constructs and displays the Page Based on json. End the process.

During the entire process, there are two key steps: one is to dynamically load the SQL statement and perform ORM ing; the other is to automatically convert and match the types of parameters required by the SQL statement for name query. If the system is large, you need to solve the problem of querying database/table sharding. This SQL method is called dynamic SQL because when the system goes online, it does not know which SQL statements will be used in the future.

Implementation Method:

Step 1. Implement servlet. Define a common servlet, jsp, or webwork/spring action, receive parameters, obtain the SQL id, and all input parameters, and then transfer them to the processing class for processing. After the processing is complete, convert the returned result to the front-end returned by json.

Step 2. implement dynamic SQL loading and query. The processing class loads and executes the SQL statement based on the id and returns the database query result. Guzz 1.2.8 beta2 provides a dynamic SQL Service Based on which you can directly implement this function. Http://code.google.com/p/guzz/wiki/TutorialDynamicSQLService

Benefits:

After implementation, the background development will be very stable and stable. Most of the work is only on the front-end page. It can greatly reduce development costs and improve development progress.

The preceding Implementation defines and manages SQL statements by uploading files, and can also be managed through databases. This makes management easier.

If you use guzz as a dynamic SQL provider, You can automatically obtain the name query, automatic type matching (converted to Enumeration type), Database sharding, automatic table sharding, custom attribute tables, and other additional support.

Zookeeper ~~
More details

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.