Java statements for database operations are prone to errors.

Source: Internet
Author: User
Let's take a look at the following statement StringsqlStringselect * frompetMessagewherepetNamepet. getPetName (); The preceding statement Selects all the information from the specified information. the left and right sides of getPetName () respectively add one pair of quotation marks to connect the string function, but carefully read the left and right sides of the quotation marks.

Let's take a look at the following statement String sqlString = select * from petMessage where petName = 'Pet. getPetName () '; The preceding statement Selects all the information from the specified information. the left and right sides of getPetName () respectively add one pair of quotation marks to connect the string function, but carefully read the left and right sides of the quotation marks.

Let's first look at the following statement

String sqlString = "select * from petMessage where petName = '" + pet. getPetName () + "';";

The preceding statement Selects all the information from the specified information. getPetName () respectively added a pair of "" to the left and right of the pair to connect to the string function, but carefully looked at the left and right of the pair, there is a symbol 'is the single quotation mark, the single quotation mark is used to enclose pet. the getPetName () Information keeps the SQL statement syntax accurate!

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.