IBatis solves SQL Injection

Source: Internet
Author: User

(1) ibatis xml configuration: The following statements are simple escape names like '% $ name $ %'
 
(2) This will cause SQL Injection problems. For example, if the parameter name is passed into a single quotation mark ('), the generated SQL statement will be: name like' %'
 
(3) The solution is to use string connection to construct the SQL statement name like '%' | '# name #' | '%'
 
(4) In this way, all parameters are pre-compiled, so there will be no SQL Injection problems.
 
(5) # differences with $:
 
# Xxx # indicates that xxx is the property value. The key in the map or the attribute in your pojo object will be automatically enclosed by quotation marks, the SQL statement is like where xxx = 'xxx ';
 
$ Xxx $ concatenates xxx into your SQL statement as a string, such as order by topicId... order by # xxx # ibatis will translate it into order by 'topid' (this will report an error) statement to write this... order by $ xxx $ ibatis will translate it into order by topicId
 
Author: 2012 gogogo !!!!!!!!!

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.