Specification for writing Database SQL statements in jsp + javabean development mode

Source: Internet
Author: User
In small and medium development teams or development projects, many people choose the jsp + javabean development mode, but in this mode, where should SQL statements be written? Many people, I will make many detours myself.
In many books, we recommend that you either write SQL statements in bean to make jsp calls (the reason is that this is more standard), or recommend that you write SQL statements in jsp files (for the convenience of development, fast development speed), but in actual development, I found that the above two methods are not very good. Next I will explain my methods and hope to get everyone's corrections.
In my opinion, when performing a list query, that is, querying a table based on certain conditions and displaying a row and a row, the SQL statement should be written in jsp, because some fields in the table must be converted into actual meanings, and two or more tables need to be associated for query. If the code is written in bean, the returned results should be converted using bean, this operation method is very bad, and it will seriously affect the running speed of the database. At this time, if the SQL statement is written in jsp and executed in bean, it accelerates the database query speed. On the contrary, it is inconvenient to develop and maintain beans (because beans are basically single-table operations ).
Principles:
A. Multiple connection queries are used to convert all data items to be converted and displayed into corresponding meanings.
B. Write the SQL statement in the jsp program, call the bean method for execution, and obtain the data result list.
When modifying a single piece of detailed information, the select query statement should be written in the bean, and the bean will return all the fields of the record, it contains the fields that need to be converted into the actual meaning of the code, and then obtain the actual meaning of these fields using the bean method. This operation is the same as the associated query operation speed.
Principles:
A. Write it in bean
B. The Jsp page does not need to care about specific SQL statements. The Parameter Id is passed in to output detailed results.
C. The data items to be converted and displayed must be read-only.
D. Data items to be converted and displayed. If editing is allowed, a drop-down list is provided to facilitate selection. The default value is the actual meaning of the data.
Related Article

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.