SQL injection vs. java

Source: Internet
Author: User
Tags basic sql injection

The previous article introduced SQL injection and experimented with PHP content primarily:

Http://www.cnblogs.com/charlesblc/p/5987951.html

This article also introduces the processing scheme (PreparedStatement in PDO or mysqli)

Http://www.cnblogs.com/charlesblc/p/5988919.html

So what is the case for Java?

First, try to avoid SQL stitching, and the parameters are quoted. Use regular filtering, front-end filtering. Use string conversions to escape processing.

Finally, try to use a precompiled statement set PreparedStatement.

The analysis shows that PreparedStatement compared with statement basically solves the problem of SQL injection, and also has a certain increase in efficiency.

PreparedStatement the parameters are escaped, do not allow the direct delivery of quotation marks;

It is not allowed to change the logical structure of SQL in the process of parameter transfer, and it is not allowed to change the logical structure of query at different insertion time.

Using the PreparedStatement provided by the interface setxxx, in the wrong type will be directly error.

Basic SQL injection is filtered (basically, because there are no breakthroughs or new vulnerabilities found in the back-attack technology now).

In addition, the Web layer allows us to filter the input of the user to prevent SQL injection such as filtering global form parameters with filter.

The Java connection database basically uses MyBatis (previously also hibernate). Bare JDBC calls are rarely used. So we don't experiment.

SQL injection vs. java

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.