Ibatis: Solves the SQL Injection problem, ibatissql

Source: Internet
Author: User

(Reproduced) ibatis: Solves the SQL Injection problem, ibatissql

Address: http://blog.csdn.net/scorpio3k/article/details/7610973

You can use the # And $ methods for ibaits parameter reference. The # method uses the pre-compilation method, and the escape is handed over to the database, so there is no injection problem. If $ is used, it is equivalent to concatenating strings, which causes injection problems.
For example, if the attribute value is "'or '1' = '1', there is no problem with the # method, and the $ method is used.
For the like statement, it is inevitable that the $ statement is used,
1. Oracle can be avoided through '%' | '# param #' | '%;
2. MySQL can be avoided through CONCAT ('%', # param #, '%;
3. Use '%' + # param # + '% in MSSQL.

Mysql: select * from t_user where name like concat ('%', # name #, '% ')
Oracle: select * from t_user where name like '%' | # name # | '%' SQL Server: select * from t_user where name like '%' + # name # + '%

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.