PreparedStatement objects and statement objects in MySQL

Source: Internet
Author: User

PreparedStatement object Compared to statement object1, the readability and maintainability of the code.2, PreparedStatement can guarantee security (solve SQL injection problem)3, PreparedStatement can improve the performance of the maximum possible:Demo
1 //SQL statements, parameters with? Instead of-----must be in English? 2String sql= "INSERT into S_user (Name,password) VALUES (?,?)";3         Try {4pstmt=connection.preparestatement (SQL);5Pstmt.setstring (1, "small yellow yellow");//Set parameter value, index starting from 16Pstmt.setstring (2, "1234567890");7             intresult=pstmt.executeupdate ();8}

PreparedStatement objects and statement objects in MySQL

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.