How to stitch SQL or other variable statements in Java

Source: Internet
Author: User

Personal talk about Java splicing SQL statement principle.

This principle is personal sentiment (not guaranteed to be completely correct)

The first rule is to write a complete string first. (For example, "SELECT * from Users where id= (id+1)")

All variables need to precede it with +, and the preceding is to add ", if not later", then you must also add + ".

The second principle if you encounter parentheses (id+1), the plus sign must die in parentheses, preceded by +, and the front is ", and the rear is +"

The third principle, if the late encounter is the variable behind there is ", it is better simply, omitted directly."

The Forth principle, if it is not a SQL statement, encounters a hyperlink statement, encounters a ", no matter what, is not", directly at the front and rear ends plus "", connect it together.

This article is from the "Jane's Life" blog, please be sure to keep this source http://1464490021.blog.51cto.com/4467028/1922865

How to stitch SQL or other variable statements in Java

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.